Linked Questions
14 questions linked to/from How to verify if a file exists in a batch file?
576 votes
3 answers
1.5m views
How to check if a file exists from inside a batch file [duplicate]
I need to run a utility only if a certain file exists. How do I do this in Windows batch?
3 votes
2 answers
16k views
Windows bat script: how to judge if a file exists? [duplicate]
Pseudo code: if file exists: do xxxx done else: do xxxx done
0 votes
1 answer
2k views
Batch checking if a file exists or not [duplicate]
I need a batch code that will tell me if test.txt is there or not it is in the same directory as the batch file. I would like to know what I should put in the space where it says the code. Can anyone ...
0 votes
0 answers
105 views
Batch script - check to see if file exists from previous iteration, if not process [duplicate]
I've had a script I've used for years...unfortunately, it isn't restartable. What I'd like to do is loop through and check to see if the files have been processed. If not, process them. The problem ...
12 votes
3 answers
21k views
Windows batch script to delete everything in a folder except one
I have a script to delete all subfolders and files in a folder: FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" & DEL /Q "D:\myfolder\*.*" And it works great! Only problem is that I would like ...
1 vote
1 answer
3k views
Remove file name prefix with cmd
I have thousands of files in one folder and most of them have prefix in name like this: NNNN_*.jpg For example 3453_dfgdhfdgh.jpg, 1000_dfgdhfdgh.jpg, 5463_dfgdhfdgh.jpg etc. How can I with CMD ...
0 votes
1 answer
830 views
How to copy files from one location to another depending on where the file does not exist
I am trying to create a script that will go through the MANY files and their locations, ensure the file exists, and if it does not exist, copy it from the location where it does. All of the files ...
-4 votes
1 answer
682 views
Notify as soon as a file in available in the folder using batch
Batch script which would notify concurrently if any file or folder is created/ copied in a certain file location. The batch file will simulate a listener. When a new file/folder is copied/created in a ...
1 vote
3 answers
414 views
Batch Script Optimization
I am working on some batch script with following code block: echo off echo SETTING UP ANT FOR THE BUILD .... set ANT_HOME=%~dp0%build\apache-ant-1.8.2 set ANT_BIN=%~dp0%build\apache-ant-1.8.2\bin ...
0 votes
1 answer
622 views
How do you specify a folder path in batch?
In Batch, I know you can always specify a folder path in batch/cmd, for example, echo %RANDOM% >> C:\Users\User\Logs\log.txt or start C:\Windows\System32\cmd.exe But what if for example, your ...
0 votes
1 answer
613 views
how to detect the existence of a txt file using a batch commands
I need to write a batch script to run on windows. I will schedule that file to run every minute on the server to test the existence of a txt file, on that server and then delete it. Wha the batch ...
0 votes
1 answer
261 views
adding code to an existing batch script to check if files exist in a directory
I would like to run a batch script with the following syntax: @echo off for %%b in ("batchscript1.bat" "bat2" "bat3" "bat4" "etc" "etc") do ( call %%b || exit /b 1 ) How could I implement code ...
1 vote
1 answer
234 views
I need help to "fine tune" my batch script (adding IF statements)
I have to: Copy a .doc file from a location to another Rename it at the new location (adding the current date to the name) Open the location where the copied/renamed file is now located Play a ...
-2 votes
1 answer
218 views
If/Else In Batch File
Syntax for batch File for IF then ELSE How to create batch File which can check if file exists then exit out else create new file?