Finding and using file date in batch command


I am trying to write what I hoped could be a simple batch program with XP command line tools. I want to find the date of a specific file, then if the date of that file is the same as the current date, the batch process would start a program. I have not been having luck. What commands do I need to use to do this?


You can use the exact following script. Save this script in file C:\Scripts\FileCheck.txt. Start biterscripting.
Enter the following command. 

script FileCheck.txt

It will do what you need. (See the code for script below.) Biterscripting is a free batch scripting environment. Follow installation instructions at .

Email me if you have any questions.


I have inserted some debug statements so you can see what the script is doing. You can remove the debug statements once you know the script is doing what it is supposed to be doing. You can even schedule this script to run automatically once a day, once a week, etc. - schedule the following command using task scheduler.

"C:\biterscripting\biterscripting.exe" "C:\Scripts\FileCheck.txt"

# START OF SCRIPT FileCheck.txt 
# Get today's date. 
var str today ; set $today = gettime() ; chex "8]" $today > $today 
echo -e "DEBUG Today is " $today 

# Set the file name whose date we want to check. 
var str file ; set $file = "C:/Something/somefile" 
echo -e "DEBUG Checking the date of file " $file 

# Get the date of the file 
var str fledate ; af -m $file > $filedate ; chex "8]" $filedate > $filedate 
echo -e "DEBUG File date is " $filedate 

# Check if the file date is same is today. 
if ($filedate == $today) 
# File date is same as today. 
echo -e "DEBUG File date is same as today" 

# Set the program to start 
var str program ; set $program = "C:/Program Files/someprogram.exe" 

# Start the program 
echo -e "DEBUG Starting program " $program 

system ("\""+$program+"\"") 


Thanks to SenHu for this tip on the forum.
Published by aakai1056. Latest update on February 16, 2010 at 08:31 AM by aakai1056.
This document, titled "Finding and using file date in batch command," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Batch script to delete file older than 30 days
BAT command to insert a char. in a file name