My source folder contains a set of target files beginning with the same root
name followed by a date/time stamp:
Example:
CompareResult_Actual_Cust_Code_&_Expected_Cust_Code_20080708_143655.txt
CompareResult_Actual_Customer_Ids_&_Expected_Customer_Ids_20080708_143655.txt
CompareResultsTally_20080708_143656.txt
The source folder also contains additional files that I do not want copied.
I use the following command (executed from a batch file) to copy these files
to another folder for archival purposes:
copy %ScriptFolder%Compare*
%ResultFolder%%yyyy%%mm%%dd%_%hrs%%min%%sec%
(%ScriptFolder% is my source folder and %ResultFolder% is my
destination folder)
Now for the rub. I want to rename the files during the copy and append the
prefix 'Archive' to the copied files. I've tried the following:
copy %ScriptFolder%Compare*
%ResultFolder%%yyyy%%mm%%dd%_%hrs%%min%%sec%\Archive*
copy %ScriptFolder%Compare*
%ResultFolder%%yyyy%%mm%%dd%_%hrs%%min%%sec%Archive*.*
copy %ScriptFolder%Compare*.*
%ResultFolder%%yyyy%%mm%%dd%_%hrs%%min%%sec%Archive*.*
copy %ScriptFolder%Compare.
%ResultFolder%%yyyy%%mm%%dd%_%hrs%%min%%sec%Archive.
All of the combinations mangle the name of the copied files to one degree or
another. I've also tried using xcopy without success (for some reason,
filename variations produced by copy and xcopy are different). The ideal
solution would not involve the use of third-party products.
Thanks for looking at this.
for %%i in (%ScriptFolder%compare*) do ECHO copy "%%i"
"%ResultFolder%%yyyy%%mm%%dd%_%hrs%%min%%sec%\archive%%~nxi"
(as one line)
* The ECHO is there to SHOW what the command would do. Remove the ECHO
keyword to actually perform the copy.
Thanks for your help billious!