Make first 4 Chars in File Name the Created Date

Started by billyjk, June 08, 2021, 07:21:22 PM

Previous topic - Next topic

billyjk

Sorry if this has been asked before, or if it can't be done in EXIFTool.

I have a large number of scanned image files with the scanned date as the "Created" date, which is of no real use to me.  Every scanned image complies to a naming standard where the first 4 characters is the year.  Is there any way to look at the first 4 chars for a file, and copy that value into the Created date, and do that as a batch run?  If so, it would help me immensely!

Thanks in advance.
- bjk


Phil Harvey

Yes.  But what do the first 4 characters signify?  A full date must be at least 6 characters, even with a 2-digit year.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

billyjk

Thanks for the quick response Phil!

I initially endeavored in my scanning process to use YYYYMMDD at the start of each file name.  But, the available date info was very incomplete, and after about 1k scans, I just dropped back to using YYYY to start file name, followed by other characters not related to date.  So, some of my initial scans have files starting with "19820128" for Jan 28, 1980, but then I just dropped back to "1982" (again, followed by other metadata) for a large number of scans.  I am ok with just being able to sort by Year, as these are all old 35mm film slides, and just knowing the year would be a good thing.

Let me know what you think.
Thanks again!
-bjk

Luuk2005

If the first numbers is always either YYYY or YYYYMMDD, and all the other numbers should be destroyed?  This could match either one, and to write them into $SomeDateTag
-SomeDateTag"<${Filename;s/^(\d{8}).*/$1 000000/; s/^(\d{4})(?!\d).*/${1}0101 000000/}"

So if you like having a different date or time, just to change the 0101 or 000000 parts.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

billyjk

Thanks Luuk2005.

Now that I know it's possible, I need to learn EXIFTool and try out your suggestion.
I'll report back.
-bjk