Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copy with Rename Question

0 views
Skip to first unread message

DJ

unread,
Jul 8, 2008, 8:15:26 PM7/8/08
to
Looking for a solution on how to copy files from one folder to another while
renaming them with a longer filename on Win XP Pro SP2 and Server2k3
platforms. I thought I was fairly command prompt 'competent' but this one
has me stumped! Maybe I'm just having a senior moment. Hehehe.

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.


billious

unread,
Jul 8, 2008, 8:59:31 PM7/8/08
to

"DJ" <ddj...@tampabay.rr.com> wrote in message
news:48740322$0$18122$9a6e...@unlimited.newshosting.com...

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.


DJ

unread,
Jul 9, 2008, 6:52:00 AM7/9/08
to

"billious" <billio...@hotmail.com> wrote in message
news:48740d81$0$8630$a82e...@reader.athenanews.com...

Thanks for your help billious!


0 new messages