Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcopy display filenames only. Not full directory path

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

like image 868
Rik Avatar asked Dec 05 '25 06:12

Rik


1 Answers

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
like image 151
xpda Avatar answered Dec 08 '25 02:12

xpda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!