File age in days | Convert the file date into Julian Days to determine the age of a file age in days. |
DOS Batch - Date and Time | Using date and time functions in DOS. |
:CmpFTime | compares the time of two files, succeeds if condition is met, fails otherwise |
:date2jdate | converts a gregorian calender date to julian day format |
:dayOfYear | returns the day of the year, i.e. 1 for 1/1/2008, 266 for 12/31/2008 |
:DeleteIfOld | deletes file or directory if older than given number of days |
:ftime | returns the file time in julian days |
:jdate | converts a date string to julian day number with respect to regional date format |
:jdate2date | converts julian days to gregorian date format |
:Unique | returns a unique string based on a date-time-stamp, YYYYMMDDhhmmsscc |
Description: | Date and Time functions are useful for:
The example in this section demonstrates how to use the :ftime function to determine the age in days of all files in the temp directory. Two variables are used
Using Delayed Expansion and exclamation marks around environment variables ensures that the `tfile`variable is substituted properly during each loop. Read more about this behavior in the SET command help (bottom half of the help text). |
||
Script: | Download: BatchFTime.bat
|
||
Script Output: |
|
Description: | call:CmpFTime op file1 file2 attr1 attr2 | ||
Script: |
|
Description: | call:date2jdate JD YYYY MM DD | ||
Script: |
|
Description: | call:dayOfYear JD DateStr | ||
Script: |
|
Description: | call:DeleteIfOld name days tnow | ||
Dependencies: | :ftime | ||
Script: |
|
Description: | call:ftime JD filename attr | ||
Dependencies: | :jdate | ||
Script: |
|
Description: | call:jdate JD DateStr | ||
Script: |
|
Description: | call:jdate2date JD YYYY MM DD | ||
Script: |
|
Description: | call:Unique ret | ||
Script: |
|