1.

Solve : Help needed using wildcards with the copy command.?

Answer»

I'm trying to copy two files from two seperate UNC's to a single directory on a single server, appending the source server name to each file to AVOID duplicate file names at the destination.

Here's an example of my failed attempts at this:

::copylogs.cmd
copy "\\server1\c$\data\*.log" "\\DestServer\c$\logs\server1_*.log"
copy "\\server2\c$\data\*.log" "\\DestServer\c$\logs\server2_*.log"
exit

I need the names to look like the following in the destination directory "servername_filename.log" But I'm having no luck finding the correct syntax? Can anyone help?

Thanks! MdaggettQuote from: mdaggett on May 14, 2007, 10:04:34 AM

I'm trying to copy two files from two seperate UNC's to a single directory on a single server, appending the source server name to each file to avoid duplicate file names at the destination.
Are there just 2 files, or 2 SETS of files? And what OS are you RUNNING?

If 2 files, you can do something like:
::copylogs.cmd
Code: [Select]copy "\\server1\c$\data\server.log" "\\DestServer\c$\logs\server1_server.log"
copy "\\server2\c$\data\server.log" "\\DestServer\c$\logs\server2_server.log"
If it is 2 sets of files, then depending on your OS, you can probably accomplish your TASK with a FOR /F loop for each set.


Discussion

No Comment Found