Discussion forum for all Windows batch related topics.
- Posts: 41
- Joined: 02 Mar 2017 05:38
What commands do I need in my batch file so that if a file exists, then continue?
If the file exists, then continue
How would I go about doing this?
Thanks in advance.
- Posts: 31
- Joined: 23 Apr 2020 13:05
You can do...
Code: Select all
if not exist c:\users\test\sample.txt [command if the file doesn't exist]
This would only do the command if the file doesn't exist. otherwise it will be ignored and your batch file be executed normally
- Posts: 4198
- Joined: 22 Jan 2010 18:01
- Location: Germany
rasil is right. Just reverse the logic.
This bails out if the file doesn't exist. In other words, it continues with the next line if the file exists.