Purpose
The aim here is to parse your file-names identifying suitable textual file dates and times, where you have incorporated something suitable in the file-name, and changing file dates as saved on disk accordingly. Suitable dates can be re-used by saving file-choices as favourites.
Mask Syntax
The procedure reads any file-names in the Folder to process (and optionally its sub-folders) and attempts to parse them. If an indicator is found it will record a suitable date combination. Then if the date can be recognised in the computer file system (after January 1st 1980) it will register the file's date as desired.
Suitable indicators of textual date are
YY or YYYY year, two or four digits (YY=a 19th, 20th or 21st Century date depending on the choice set above)
MM month
DD day
* skip all characters until a digit is found
The procedure doesn't understand words such as "December" or "Five", it only uses digits. Any character other than Y,M,D,* in the mask simply gets ignored.
Show file Dates & Times
If you choose this button, the program simply examines all the text files found and lists all different file-dates and times as stored on the file system, ignoring the Mask. It lists results in the Results file. The point of it is to check whether your texts cover the range of times & dates you expect.
Make list and set file date using Mask
The program will always add each entry found to a simple text file (Results file) listing its file-name and adding a suitable date as expected in the auto-date procedure, (or <no date found> if the mask didn't match a valid date). In addition, where the result is 1st January 1980 or later, it will set the file's time and date in the operating system to the date as parsed, so that WordSmith will automatically match the date of the text contents to the date stored on disk.
When all files have been processed, the program opens the list of files in Notepad or equivalent. Use it afterwards in the auto-date procedure within file-choosing and save your preferred text files as favourites.
The idea is to find a header in each text and extract the date, then set the file-system to that date. Use the Find header date and set it button.
If the required header is found in the text the file will get its date set to that date.
Example: the setting shown in the screen-shot with header as Date and the English-language months listed with commas separating them will find
the year 2022, month 12 and day 31 in this text. Then it will ensure the file is set to that date.
Examples
The example in the picture above looks at each text file. If its file-name starts with any five characters, then an underscore, then five more characters, then another underscore, then a two-digit sequence, an underscore, another 2-digit sequence, another underscore, four digits, another underscore it will try to assume the first two digits are a day (between 1 and 31), the second two are a month (1-12) and the other four are a year. If all these assumptions are OK it will list the file with that date in a text file (c:\temp\result_dates.txt) and if the date is later than 1980, set the file's date in the computer's file system to the correct date desired, thus matching its file-name.
Your Mask |
Source file-name |
Date and Time interpreted |
YYYYMMDD |
20060512 Peter monologue.txt |
12th May 2006 (first 8 characters used in the mask) |
YYMMDD |
841231.txt |
31st December 1984 (20th Century assumed if YY mask used) |
DDMMYY |
311284.txt |
31st December 1984 |
DDMMYYYY |
20060512 Peter monologue.txt |
20th June, the year 512 AD |
DDMM |
20060512 Peter monologue.txt |
20th June of the current year |
######YYYYMMDD |
Peter 20060512.txt |
12th May 2006 (first six characters were ignored, five for Peter, one for space) |
*YYYY |
Peter 20060512.txt |
15 July 2006 (all characters to first digit skipped, then next 4 used for year date) |
YYYY |
1086 Domesday book.txt |
15 July 1086 (there were only four digits) |
YYYYMMDD |
1086 Domesday book.txt |
15 July 1086 (mask had 8 digits but file-name only 4) |
YYYY#MM#DD |
2006,05/12,10-54.txt |
12th May 2006 |
YYYY MM DD |
2006,05/12,10-54.txt |
12th May 2006 |
?YYYY?MM?DD |
T2015_11_27 discussion.txt |
27th November 2015 (T at beginning of file-name ignored) |