Computing.Net > Forums > Windows XP > Batch copy files if not exist

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch copy files if not exist

Reply to Message Icon

Name: PeterHR
Date: January 31, 2009 at 06:27:22 Pacific
OS: Windows XP
CPU/Ram: 2.5GHz/4GB
Product: Acer / ASPIRE
Subcategory: General
Comment:

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




Response Number 1
Name: Ed in Texas.
Date: February 1, 2009 at 00:57:44 Pacific
+1
Reply:

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.



Response Number 2
Name: PeterHR
Date: February 1, 2009 at 03:50:30 Pacific
+1
Reply:

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\



Reply to Message Icon

Related Posts

See More


Cannot Delete File removing password of hidd...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Google Ads



Results for: Batch copy files if not exist

Copy files according to Date Mdified www.computing.net/answers/windows-xp/copy-files-according-to-date-mdified/176041.html

script to add files if not present www.computing.net/answers/windows-xp/script-to-add-files-if-not-present/180953.html

Copy the name of one file and renam www.computing.net/answers/windows-xp/copy-the-name-of-one-file-and-renam/165255.html