Computing.Net > Forums > Programming > Batch IF EXIST ... ELSE

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 IF EXIST ... ELSE

Reply to Message Icon

Name: astroraptor
Date: October 9, 2007 at 06:22:29 Pacific
OS: Windows XP Pro
CPU/Ram: 2.66GHz/2048MB
Comment:

I wrote a batch file to retrieve data from a FTP server. Basically, it formats a temporary file which the batch then filters through checking to see if files already exist in a specific location before downloading or not. I've checked the %tmpfile%.updates file and it does contain valid filenames and it's hard to believe that after over a week there are no updates available on the site. So at this point, I'm thinking it's a fault in my coding. Can anyone help me figure it out? Thanks.
----
For /F "tokens=4" %%n in ('Type %tmpfile%.updates') Do If Not Exist %destination%\%%n (Goto GetFiles) Else Goto Clean



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: October 9, 2007 at 15:43:40 Pacific
Reply:

What does the file %tmpfile%.updates contain?
Also, what is %destination%?

Try this:

@echo off
For /F "tokens=4" %%n in ('Type %tmpfile%.updates') Do (
If Not Exist %destination%\%%n (
Goto GetFiles
) Else (
Goto Clean
)
)

One way to tell if your script contains syntax error's is by running it from the command prompt with echo turned on. To do this, change this line @echo off to ::@echo off, then run it from a command prompt.

"Computer security." — Oxymoron


0

Response Number 2
Name: astroraptor
Date: October 10, 2007 at 13:06:09 Pacific
Reply:

I found out what the problem is. My original code's actualy fine. It turns out the code I wrote in order to sort the latest files is incorrect. It's sorting it alphabetically, so updates from September are showing up, so it's pulling updates from then. Another thing to rack my brain. But, when you love coding, there's nothing to worry about. Thanks for your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Batch file Renaming Help survey to csv



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch IF EXIST ... ELSE

Loopinig batch file using IF EXIST www.computing.net/answers/programming/loopinig-batch-file-using-if-exist/17323.html

Batch - if [not] exist www.computing.net/answers/programming/batch-if-not-exist/11906.html

Batch For DO(list of if exist set)? www.computing.net/answers/programming/batch-for-dolist-of-if-exist-set/16087.html