1

I have my old scanned photographs sorted in folders named by the year they were probably taken (1970, 1971 etc); the folder names are just the plain years without any other text. Is it possible to let ExifTool change the Exif date to, say 1.1.<foldername> for all files in the various folders? (January 1st just because no more specific date is known at this point) Any other (free) tool is of course as appreciated.

6
  • 1
    It's probably possible, but more details on the directory path would be needed. Is the folder name just the year or are there other numbers in the path? – StarGeek Jan 2 at 16:26
  • 1
    Exiftool can change the date to whatever you want it to be, so the question then becomes how do you determine the value that you want the date to be set to? Batch mode parsing the directory tree to obtain that value is going to be a function of the OS that you are using. Which to me suggests that this is not primarily a photography question, and may be better answered on another (OS dependent) SE site – Peter M Jan 2 at 18:14
  • Almost certainly it is possible by writing a “relatively’ simple computer program using a shell or scripting language. The relatively depends on your relative programming proficiency and the pleasure you find in such tasks. – Bob Macaroni McStevens Jan 3 at 14:19
  • @StarGeek The directory names are just the plain years. I edited the question accordingly. – cirko Jan 3 at 17:05
  • @PeterM I thought it might be similar to this question, that's why I ended up posting it here – cirko Jan 3 at 17:07
2

This can be done with exiftool with this command
exiftool "-Alldates<${Directory;m/(\d{4})/;$_=$1} 0101 000000" /path/to/files/

There are some limitations. You must give a directory path that includes the year i.e. you can't CD to that directory and use a dot to indicate the current directory, though you can be in the directory above the years and use the -r option to recurse. There can't be any other group of four numbers in the directory path, as that could be mistaken for a year. Any differences would need modification of command.

This command uses exiftool's Advanced formatting feature to regex match four digits to use as the year. It then sets the three most common EXIF timestamps, DateTimeOriginal, CreateDate, and ModifyDate to YEAR-01-01 00:00:00.

This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.

2
  • I'm on a Mac. I did it from the parent directory and had to change it to exiftool '-Alldates<${Directory;m/(\d{4})/$_=$1} 0101 000000' * -r -overwrite_original for it to work. I got the Warning: syntax error for 'Directory' - (path/filename) for every single file (is that serious?), but it did change the Exifs, so - it works! – cirko Jan 3 at 20:53
  • Ooops, I forgot a semicolon before the $_ (fixed). Double check to make sure it worked correctly but it still might have worked if there were no extra numbers in the Directory path exiftool received. I think that's why it worked regardless of my error. – StarGeek Jan 3 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.