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.
It will do what you need. (See the code for script below.) Biterscripting is a free batch scripting environment. Follow installation instructions at http://www.biterscripting.com/install.html .
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.
# 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" # ****** ENTER CORRECT FILE LOCATION ABOVE ****** 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" # ****** ENTER CORRECT PROGRAM LOCATION ABOVE ********** # Start the program echo -e "DEBUG Starting program " $program system ("\""+$program+"\"") endif # END OF SCRIPT
Thanks to SenHu for this tip on the forum.