COPY Copy one local file to another location
<< Click to Display Table of Contents >> Navigation: Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands > COPY Copy one local file to another location |
Syntax: |
COPY |
[ src file ] [ dest file ] |
Arguments: |
[ src name ] |
Variable or string defining a file or path name; if no path is defined Robo-FTP’s working folder is used. Wildcards are supported. |
|
[ dest name ] |
Variable or string defining a file or path name; if no path is defined Robo-FTP’s working folder is used. |
Options: |
/subdirs |
Search sub-directories for files to copy |
|
/flat |
Don't copy sub-directory to destination when using /subdirs |
|
/allowerrors |
Continue to next file to be copied on error instead of simply stopping and reporting error. |
|
/link |
hard link source files into destination instead of copying. This is useful if you need to copy files to a different location on the same drive but don't want to waste space by actually allocating two copies of the file. |
|
/emptydirs |
Copy empty sub-directories to destination. |
|
/copydirs |
Copies the file to a destination directory that corresponds to the directory path portion of the [ src name ] argument. Destination directories are created if necessary. The final destination directory is calculated relative to the current local working directory so this option requires that the source file(s) be located either in the working directory or a subdirectory of the working directory. This option is commonly used when variables like %nextpath or %difffilepath are passed to the [ file name ] argument. |
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
The following copies all files and folders in C:\test to C:\test2\test. It will create C:\test2\test if it doesn't exist. Note the trailing "\" in the second argument to COPY:
COPY "c:\test" "c:\test2\" /subdirs /emptydirs
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