Batch Script - Moving Folders



For moving folders, Batch Script provides the MOVE command.

Syntax

MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

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

S.No. Options & Description
1.

[drive:][path]filename1

Specifies the location and name of the file or files you want to move

2.

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.

3.

[drive:][path]dirname1

Specifies the directory you want to rename.

4.

dirname2

Specifies the new name of the directory.

5.

/Y

Suppresses prompting to confirm you want to overwrite an existing destination file.

6.

/-Y

Causes prompting to confirm you want to overwrite an existing destination file.

Let’s look at some examples of moving folders.

Examples

move *.* C:\Example

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

move *.txt C:\Example

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

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

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

batch_script_functions.htm
Advertisements