Skip to main content

Batch Script Moving Folders

Moving Folders

Batch Script provides the move command for moving folders.

move [/y | /-y] [drive:][path]filename1[,...] destination

Following are the description of the options which can be presented to the move command.

OptionsDescription
[drive:][path]filename1Specifies the location and name of the file or files you want to move
destinationSpecifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a filename if you want to rename the file when you move it.
[drive:][path]dirname1Specifies the directory you want to rename.
dirname2Specifies the new name of the directory.
/ySuppresses prompting to confirm you want to overwrite an existing destination file.
/-yCauses prompting to confirm you want to overwrite an existing destination file.
warning

You can only move directories within the same drive!

Otherwise, you will get an accessed denied error.

note

The move command does not touch the file itself: it only changes the file allocation table.

This is why a file cannot be moved to another drive, and any move to another drive must be done using a copy.

Examples

Let’s look at some examples of moving folders.

The following command will move all files from the current directory to the folder C:\Example.

move *.* C:\Example

The following command will move all files with the .txt extension from the current directory to the folder C:\Example.

move *.txt C:\Example

The following command will move all files from the folder called old in C drive to the folder C:\Example.

move C:\old\*.* C:\Example

Table of Contents