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
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
+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\
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...