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! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to 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



Sponsored Link
Ads by Google

Response Number 1
Name: Ed in Texas.
Date: February 1, 2009 at 00:57:44 Pacific
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.


0

Response Number 2
Name: PeterHR
Date: February 1, 2009 at 03:50:30 Pacific
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\


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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


Sponsored links

Ads by Google


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

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

bat file copy to desktop www.computing.net/answers/windows-xp/bat-file-copy-to-desktop/121757.html