Batch Script - Moving Files


Advertisements

For moving files, 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 renaming files.

Examples

move c:\windows\temp\*.* c:\temp

The above command will move the files of c:\windows\temp to the temp directory in root.

move new.txt, test.txt c:\example

The above command will move the files new.txt and test.txt into the c:\example folder.

batch_script_functions.htm
Advertisements