Batch copy files if not exist

Acer / ASPIRE
January 31, 2009 at 06:27:22
Specs: Windows XP, 2.5GHz/4GB
Hi,

I would like to recursively copy files to a single directory via batch file if files do not exist. If the files already exist in dir they should skip. I tried following, but copies files even if exist.

for /r %%d in (*filename*.tar) do copy "%%d" C:\mydata\

How can I solve this?

Thanks in advance!

Peter


See More: Batch copy files if not exist

Report •


#1
February 1, 2009 at 00:57:44
PeterHR, SWAG, you need an if/then/else statement first. Have it do the comparison first and do the copy only if the criteria are met.
HTH.
Ed in Texas.

Report •

#2
February 1, 2009 at 03:50:30
Ed in Texas, thanks for your help. I understand the principle but how should the code look like? The following code doesn't work.

for /r %%d in (*filename*.tar) do if not exist C:\mydata\%%d copy "%%d" C:\mydata\


Report •

Related Solutions


Ask Question