Reputation: 57
I want to copy files from two directories on a remote computer to a single directory on a windows server. In one directory I have files with the extension *.csv and in the other *.asc. Drives have been mapped with the UNC convention so we have drives such as Z:\ which are mapped to a specific folder on another computer. The scripts can reside in either the remote computer or on the windows server.
The files with the *.asc extension are then processed and then need to be renamed or moved to another directory (which our software does). The files with the *.csv extension are not changed
I tried using Robocopy and this worked with the MOVE switch
c:\scripts\ROBOCOPY.exe z:\ C:\files\Magellan /MOV /NP /R:2 /W:2 *.asc >c:\scripts\synchro.log
However, the source programme / software requires that these *.asc remain in the original source location - so I can`t use the move switch.
I don`t want to copy duplicate *.asc files - otherwise these files will be processed again.
So I need to only copy new files - ie files that have not been copied before and compare them to another location where the file has either been renamed or moved !
Upvotes: 1
Views: 1238
Reputation: 1660
Pick the order you want to run these lines in (and fix up the mapped drive letters). That said, I'm not sure that you just want to copy both csv and asc files to the Magellan directory as your question mentions comparing them to another location.
echo n|copy /-y z:\*.csv c:\files\Magellan
echo n|copy /-y y:\*.asc c:\files\Magellan\*.csv
Upvotes: 0
Reputation: 57242
@echo off
pushd Z:\
for %%# in (*.csv) do (
echo n|copy /-Y "%%~f#" "C:\files\Magellan\"
)
for %%# in (*.asc) do (
echo n|copy /-Y "%%~f#" "C:\files\Magellan\%%~n#.csv"
)
try this.If your language settings are different than english you might need to change the echo n
that applies to your language.Not sure if this can be done with robocopy or xcopy (I need to read their help in details).This will copy/move first the .csv
files and then the .asc
files . You can change the order and where is needed you can replace the copy
command with move
Upvotes: 1