Batch Script to copy new files only

时间:2015-07-31 19:20:48

标签: javascript c# .net batch-file echo

I have a small batch script to move files from shared to location to my E-drive. The script below moves the file from the shared location and deletes it from the shared location.

@echo off
cls

NET USE Q: \\lMC-Wheat-tick\PQ120R2A3 /USER:SAPQMPQ-LOCAL\USername       "Password"

move "Q:\*.csv" "E:\CSV Files\CSV\CSVSource\"

NET USE Q: /DELETE /Y
echo on

I want to modify this code not to delete the file in shared location and pick only the files from the shared location that are not in my E-Drive ("E:\CSV Files\CSV\CSVSource\").

Thanks in advance.

1 个答案:

答案 0 :(得分:1)

@echo off
cls

NET USE Q: \\lMC-Wheat-tick\PQ120R2A3 /USER:SAPQMPQ-LOCAL\USername       "Password"

echo n|copy /-Y "Q:\*.csv" "E:\CSV Files\CSV\CSVSource\"

echo on

-Y在覆盖之前提示,您可以将n管道输出到所有这些问题。所以这实际上只是复制不存在的文件。