Search : in
By :

Finding and using file date in batch command

Last answer on May 19, 2009 10:35:33 pm BST TWriter, on Apr 14, 2009 6:43:38 pm BST 
 Report this message to moderators

Hello,
(I posted this question to the wrong category (Windows) so I'm re-posting here.)

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?

Thanks in advance.

Configuration: Windows XP
Firefox 3.0.8

Best answers for « Finding and using file date in batch command » in :
Windows is not find the file with.exe extension Show Windows is not find the file with.exe extension What to do? What if your computer is infected? It can happen sometimes that while running a program/application/particular software, Windows does not find the particular extension...
Cannot find script file [C:WINDOWSsowar.vbs] Show Cannot find script file "C:\WINDOWS\sowar.vbs" Issue Solution Issue Whenever I start my laptop I get: Cannot find script file "C:\WINDOWS\sowar.vbs". I think this is a virus. What should I do to resolve this one? Another thing,...
Renaming multiple files in batch ShowRenaming multiple files in batch Native features Using a third-party program Renaming a large number of files can quickly become tedious. Fortunately, there are tools to automate this task in many cases: Native features On Windows...
Writing in batch in text file ShowWriting in batch in text file To write in a file text, you just have to use a redirect: echo text > output_file.txt To write in an existing file: echo " Write at the end of the file ">> output_file.txt
Phpize: command not found Showphpize: command not found Though you have installed the PHP programming language on your computer, you will be required to install the extension pecl to be able to run its commands. Else, you will be face with the error message...
Download Find Junk Files ShowThe most part of applications on Windows create temporary files on your hard disk during their functioning. These files are assumed be abolished and the space recovered during the closing of program, but it is not always case. In the course of time,...
Environment variables ShowEnvironment variables An environment variable is a dynamic value loaded into the memory that can be used by several processes operating simultaneously. On most operating systems, the location of some libraries or of the main system executables may...
UNIX Commands ShowTable of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...
UNIX system - The shell ShowIntroduction to the shell The command interpreter is the interface between the user and the operating system, hence its name "shell". The shell therefore acts as an intermediary between the operating system and the user using command lines...

1

SenHu, on Apr 25, 2009 2:04:05 pm BST
  • +2

Hello:

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 http://www.biterscripting.com/install.html .

Email me if you have any questions.

Sen

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"
# ****** 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

Reply to SenHu

2

TWriter, on May 12, 2009 4:21:48 pm BST

Thank you! It works well.

Reply to TWriter

3

 SenHu, on May 19, 2009 10:35:33 pm BST

Cool.

Sen

Reply to SenHu