Moving Files Using the Command Line

by Barry Dysert
(last updated January 16, 2017)

1

If you don't mind doing a little more typing and a little less mouse clicking, you can perform a lot of actions from the command line. (Displaying the Command Prompt window is covered under another tip.) One thing you can do from the command line is to move files. The command-line command you use is MOVE and it takes two (or more) parameters. The first parameter specifies the file you want moved and the second parameter specifies to where the file should be moved.

So let's say you have a file called "C:\Temp\BatFun.bat" and you want to move it to C:\Bat\BatFun.bat You would type the following at the command line:

C:\> MOVE C:\Temp\BatFun.bat C:\Bat\BatFun.bat

The BatFun.bat file in the \Temp directory will be moved to the \Bat directory. It will no longer exist in the C:\Temp directory, which is the main difference between COPY and MOVE. (See the tip titled Moving Files Using the Command Line for details of the COPY command.) Of course, you can specify whatever name you like for the destination, so you may have a \Temp\BatFun.bat file that you're developing and testing, but once you're satisfied with it you may want to move it to your \Bat directory and give it the name of DirList.bat. This is accomplished by just changing the name of the destination parameter:

C:\> MOVE C:\Temp\BatFun.bat C:\Bat\DirList.bat

You can use wildcard characters to move multiple files at a time. So let's say you have several .bat files in your \Temp directory that are supposed to work together, and you want to move them all to your \Bat directory. Maybe the files are named C:\Temp\Dir1.bat, C:\Temp\Dir2.bat, and C:\Temp\Dir3.bat. To move them all to your \Bat directory the command would be:

C:\> MOVE C:\Temp\Dir?.bat C:\Bat

The wildcard character "?" stands for exactly one actual character in the source parameter. Note that you didn't need to specify anything except the destination directory (without the trailing backslash) as the second parameter. This is because MOVE will automatically use the file name specified by the first parameter as the file name to be used in the \Bat directory. In other words, you'll end up with a Dir1.bat, Dir2.bat, and Dir3.bat in your C:\Bat directory.

The MOVE command is similar to the COPY command but with two main differences:

  1. You cannot concatenate files with the MOVE command.
  2. MOVE removes the file from the source location instead of leaving it there.

 This tip (13101) applies to Windows 7, 8, and 10.

Author Bio

Barry Dysert

Barry has been a computer professional for over 30 years, working in different positions such as technical team leader, project manager, and software developer.  He is currently a senior software engineer with an emphasis on developing custom applications under Microsoft Windows. ...

MORE FROM BARRY

Creating a Media Player Playlist

Windows Media Player lets you manager all sorts of media. One way to do this is by creating playlists. This tip describes how ...

Discover More

Creating a System Image

A system image is a snapshot of your system disk as of a certain point in time. Should the need arise, you can restore your ...

Discover More

Copying Data with XCopy

XCopy is a file and directory copy utility built into Windows. If you have a lot of file management to do that can't easily ...

Discover More
More WindowsTips

Displaying the Command Prompt in Windows 8

Some commands require the use of the command prompt window. How you display that essential window in Windows 8 can be a bit ...

Discover More

Using the Findstr Command

Finding data within files is a common need. If what you're looking for is in a flat file, you can find what you're after ...

Discover More

Using the Sort Command

Sorting data is a common task even of end users. Fortunately, The Windows command line provides us with a Sort utility so we ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 - 0?

2017-01-19 19:02:34

Gordon Schochet

It is even easier to move files with a program that includes "move" and "copy" to another folder options in in the right click.


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.