Windows Batch Script-To check for file's existence using partial name

Preethi_raju

Prominent
May 23, 2017
1
0
510
Hi,

I am new to windows batch scripting. So please help me with this, I have jar file and if i run it, an output file will be produced with this name as output_date_time. ie., if today's date is 22/5/2017.. time is 11.20:30 seconds the output file name will be output_2552017_112030. I need to write a batch script to check whether output is generated or not. Since the file generated by the jar file has included seconds as well , i wanted to know whether this is possible or not: output_2252017_1120* ie to check whether output file got generated with the date and time without seconds. Please help
 
Solution
Making a variable from system date/time in batch files to test against the file name is difficult and depends much on the format of the system date/time (DD/MM/YYYY or MM/DD/YYYY etc. and 12 or 24 hour format of time).

Here is a rudimentary batch file that should do the job. No path is included so it must be run from within the same folder as the file it looks for. Also the file name/date will have to be manually edited each day, hour and minute.

IF EXIST output_2252017_1120*.* GOTO File_exist
ECHO File doesn't exist
PAUSE
GOTO :EOF
:File_exist
ECHO File does exist
PAUSE
:EOF

Nigel
Making a variable from system date/time in batch files to test against the file name is difficult and depends much on the format of the system date/time (DD/MM/YYYY or MM/DD/YYYY etc. and 12 or 24 hour format of time).

Here is a rudimentary batch file that should do the job. No path is included so it must be run from within the same folder as the file it looks for. Also the file name/date will have to be manually edited each day, hour and minute.

IF EXIST output_2252017_1120*.* GOTO File_exist
ECHO File doesn't exist
PAUSE
GOTO :EOF
:File_exist
ECHO File does exist
PAUSE
:EOF

Nigel
 
Solution