Friday, January 27, 2012

FileDater

File Dater is a utility for working with files that have the date in the filename such as log files or images automatically captured by a camera. It can preform a copy, a move or just display lists.

Example:

FileDater commands.fd

comands.fd is a file dater command file like:
FORMAT 'QRTRYWAY2_'yyyy-MM-dd_HH-mm'.jpg'
FOLDER C:\temp\QRTRWAY2\
AFTER 7:00
BEFORE 19:00
EXCLUDE dddd Saturday
EXCLUDE dddd Sunday
NEWER 70 days
OLDER 69 days
FILTER
SHOW
MOVE C:\temp\qtr4\ image Count
#comment

Each line of the file is processed one at a time to get the results you want. The first two lines are always FORMAT and FOLDER.

FORMAT FilenameFormat
This command establishes the format for the file you will be working with and example filename from above would have been QRTRYWAY2_2012-01-20_13-40.jpg

FOLDER Folder
This is your source folder.

AFTER DateTime
BEFORE DateTime
This will include or exclude files after a Date or Time. if DateTime only includes a time then it will use that as time of day so in the example above I am grabbing files furring the day from 7 am to 7 pm.

EXCLUDE DateFormatString value
This will exclude any files where the date formatted as per DateFormatString == value. In the above eexample this will exclude weekends but this could almost be used to exclude every file marked with the 3rd of  the month.

INCLUDE DateFormatString value
Similar to exclude but will exclude all files that don't match so this could be used to say only grab the file dates 5 minutes after the hour. Having more that one INCLUDE will return very few results you can't include Sunday and Saturday to get the weekend you need to EXCLUDE the entire work week.

NEWER TimeSpan
OLDER TimeSpan
This will exclude any files that are not dated newer than or older than a given date. In my example I'm looking for NEWER 70 days and OLDER 69 so I want all new files in the last 70 days that are atleast 69 days old. This gives me 24 hours worth of files. A use for this is to find the newest files and copy them somewhere or find old files like log files over a month old and move them somewhere. You could setup a script to move old log files to a folder then zip it up.

FILTER
This will preform all the above operations on every found file.

SHOW Optional Format String
This will show the files found. It will show the new filename, so if you call this before a copy you get the original file name, after you get the new file names. A format string is separated by spaces and can contain the following keywords "Count",  the number for the file in the result set, OriginalFilename, NewFilename. You can also include a % followed immediately by and date format string.  The above file names could be recreated as "QRTRYWAY2_ yyyy-MM-dd_HH-mm .jpg to print the file name, almost. All options are spaced apart so you would get QRTRYWAY2_ 2012-01-20_13-40 .jpg.

COPY DestinationFolder format
MOVE DestinationFolder format
Copies or moves the resulting files to a destination folder. This could be the same folder with a different file name structure. This way you can use Move like a copy. Warning: Copy and move will replace any files in the target location that have matching names without warning you. The example line "MOVE C:\temp\qtr4\ image Count" will move all the matched filed to a new folder and rename then to image0001.jpg for example. The number of digits in Count is based on how big the result set is but is always fixed length. This is useful if you later want to sort the file by name. File extensions are preserved.

Please note the application does very little error checking and might just crash. If you have questions or requested feature please let me know.

Download


1 comment:

  1. Merkur 37C Safety Razor Review – Merkur 37C
    The Merkur 37c is an excellent short kadangpintar handled DE 토토사이트 safety razor. It is more suitable deccasino for both heavy and non-slip hands and is therefore a great 도레미시디 출장샵 option for experienced febcasino

    ReplyDelete