Skip to content

Batch Script Moving Folders

Learn how to use the move command in Windows Batch Script to relocate folders within the same drive, including syntax, options like /y for overwrite suppression, and practical examples.

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.

Options Description
[drive:][path]filename1 Specifies the location and name of the file or files you want to move
destination Specifies 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]dirname1 Specifies the directory you want to rename.
dirname2 Specifies the new name of the directory.
/y Suppresses prompting to confirm you want to overwrite an existing destination file.
/-y Causes prompting to confirm you want to overwrite an existing destination file.

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
Navigation