computing
  • 5

Solved I Want Xcopy To Both Copy and Rename Multiple Files

  • 5

I can easily use xcopy to copy files to another location

xcopy “\\Source\*.*” “\\Destination\” /y/s

but I would then like the copied files to be renamed to append “Copy of ” or similar to the start of the file.

I have managed code which will replace the first 8 characters of the filename

xcopy “Source\*.*” “destination\Copy of *.*” /y /s

but haven’t a way of appending this.

Can anyone help?

Share

1 Answer

  1. Easiest solution is just to use copy instead of xcopy:

    for %%a in (H:\Source\*) do copy /y "%%a" "H:\Destination\Copy of %%~NXa"

    (Note: H:\Destination needs to exist before this command runs.)

    How To Ask Questions The Smart Way

    • 0