cop[+|-|!] from to [flags] ren[*|+|-|!] from to [flags]
from - source file or folder.
to - destination folder or file. If option * (rename) used, must be new filename without path.
|Default||if destination file already exists, ask what to do (show dialog).|
|+||if destination file already exists, rename the copied or moved file.|
|-||if destination file already exists, replace it.|
|!||if destination file already exists, error. You can use err to continue. This option cannot be used with list of files.|
|* (with ren)||rename. Default: move, or move and rename.|
cop copies a file or folder.
ren moves or/and renames a file or folder.
Like all QM file functions, support special folders. Also support relative paths (in QM 2.3.0 and above it works better).
To copy or move multiple files, can be used one of the following:
1. Use wildcard characters in filename part of from. Then to must be folder. All matching files will be copied to the folder. To copy matching subfolders too, FOF_FILESONLY flag must be removed. Use the 'Copy Files' dialog or 'Move/Rename Files' dialog to insert correct flags.
2. Use list of files (full paths) in from, one file in a line. Then to can be either single folder or list of destination files.
3. Enumerate files. To insert the code, use the 'Enumerate Files' dialog.
The functions work in the same way as if the user would do it manually. They are quite slow with small files, especially on Vista. You can instead use faster functions: FileCopy, FileMove and FileRename.
QM 2.3.0. Removed autodelay.
Drag and drop a file onto the macro text to insert full path.
Copy file "x.txt" from "c:\a" to "c:\b" folder: cop "c:\a\x.txt" "c:\b\x.txt" Copy file. If "c:\b\x.txt" already exists, copy with name "Copy of x": cop+ "c:\a\x.txt" "c:\b\x.txt" Copy file. If "c:\b\x.txt" already exists, delete it: cop- "c:\a\x.txt" "c:\b\x.txt" Copy all text files from "c:\a" to "c:\b" folder: cop "c:\a\*.txt" "c:\b" Copy all files (but not subfolders): cop "c:\a\*.*" "c:\b" Copy file; use variables: str sfrom = "c:\a\x.txt" str sto = "c:\b\x.txt" cop sfrom sto Move file "g.gif" from "c:\a" to "c:\b" folder: ren "c:\a\g.gif" "c:\b" Rename file g.gif to h.gif: ren "c:\a\g.gif" "c:\a\h.gif" The same: ren* "c:\a\g.gif" "h.gif" Copy multiple files from My Documents to a folder on desktop: lpstr dest="$desktop$\from my doc" mkdir dest lpstr files= $personal$\book1.xls $personal$\page1.htm $personal$\document1.doc cop files dest