How to change drive from within a Microsoft Windows batch file?

The Microsoft Windows Command Line batch file is a powerful technique to automate repeated tasks. Quite frequently, you will be in need of changing a drive in a .bat script. This can be accomplished using the below command from within .bat script:

cd /D <drive>

Example:

cd /D G:

To navigate to a directory within some drive from some other drive, try:

cd /D <drive>:\<folder>

Example:

cd /D G:\foo


References:

Advertisements

2 thoughts on “How to change drive from within a Microsoft Windows batch file?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s