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
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\
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\
Summary: Try this, it is untested... You must provide the path to the files in the Pushd command line. :: Code begins... @echo off cls setlocal enabledelayedexpansion :: The only validity checking is that the...
Summary: Hi all i have a problem i need some help with this what i want to do is i have one file now i patch it and it saves a another file ie. patched.*** now what i want to do is see if i can keep the origin...
Summary: In a word, NO. :-) Why not use IF NOT EXIST statements in batch file? Something like this: IF NOT EXIST "C:\Documents and Settings\All Users\Desktop" THEN GOTO WIN98 Copy <source> <destination> ...