3

Any way when copying files via Xcopy (via batch) to output the filenames of the files being copied - or better yet, the base folder and filename - rather than the whole directory path?

The batch uses %USERPROFILE%\Desktop which resolves to C:\Documents and Settings\Username\ and then Desktop. Then that's where the folder lives with the files and directories to be copied. Of course when it copies across you see C:\Documents and Settings\Username\Desktop\TheFolder\SubFolder\filename.txt in the output window, which takes up 2 lines per copy and just looks terrible when you are trying to see where its up to.

All I want to see is SubFolder\filename.txt

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
Rik
  • 91
  • 1
  • 10

1 Answers1

3

Use cd /folder to change to the source folder (or one above it), and in the xcopy statement, don't include the entire path.

For example, instead of this...

xcopy c:\tmp\q\z\*.* c:\destfolder

...do this:

cd \tmp\q
xcopy z\*.* c:\destfolder

And to copy from the desktop:

cd %userprofile%
xcopy desktop\*.* c:\destfolder
xpda
  • 15,585
  • 8
  • 51
  • 82