Wednesday, March 18, 2009

Using xcopy in batches/scripts

I like using xcopy to copy files because it has an option to print out the source and destination file paths during the copy (/f). Unfortunately it's got some quirky behavior; if you're changing the name of the file you're copying then it asks you if the target is a file or directory. This is a royal pain because much of my xcopy use occurs in the context of non-interactively executed .bat files.

Finally figured out a way to teach .bat files to answer xcopy. It's laughably simple, don't know why I didn't think of it sooner:

echo f ¦ xcopy /f source.file renamed.dest.file

Coming from the unix world you'd think that'd be the first thing to come to mind.... :(

No comments :

Post a Comment