COPY Copy one local file to another location |
Top Previous Next |
Use this script command to copy the source file to the destination location.
For example, the following copies a file to a new folder and renames it.
COPY "c:\test\file" "c:\test2\file2"
If test2 is an existing folder, the following copies a file to the folder while retaining the original file name.
COPY "c:\test\file" "c:\test2"
Otherwise, file is copied to the root folder of drive C: and renamed to test2.
If test2 is an existing folder, the following copies all files in C:\test to C:\test2
COPY "c:\test\*" "c:\test2"
The following copies all files and directories in C:\test to C:\test2. It will create C:\test2 if it doesn't exist.
COPY "c:\test" "c:\test2" /subdirs
In this example, the /copydirs option is used to preserve the source directory structure in the destination folder:
:next GETFILE "*" /subdirs IFERROR GOTO exit COPY %nextpath "c:\destination" /copydirs GOTO next :exit
After any files have been copied, the %copyfiles internal script variable is automatically populated with the destination path of all such files.
Related command(s): MOVE, RENAME, MAKEFILENAME, APPEND, DELETE, DOSCMD, WORKINGDIR, Using the %copyfiles Variable
|