is there a way to assign CreateDate to the image if it doesn't exist

Started by bungaman, March 08, 2021, 09:41:44 AM

Previous topic - Next topic

bungaman

was wondering whether it was possible to assign a CreateDate to an image based on the containing folder name for the image? 

so keep CreateDate if it already exists, but if not, if the folder name containing the image is "2007" then assign "2007-01-01" as the CreateDate.

StarGeek

As long as there are no other numbers in the directory path and you don't CD to the directory the file is in and use a dot . as the directory name
exiftool -wm cg "-CreateDate<$Directory 01:01 00:00:00" /path/to/2007/

The -wm (writemode) option with cg parameters will not overwrite existing tags.

See FAQ #5 for more details on setting time stamps.

The above command sets the CreateDate to midnight, January 1 on the year taken from the directory path.
You can't CD to the directory and use a dot or a wildcard such as *.jpg to indicate the files to process as that sets the Directory to a value of dot . and that obviously doesn't contain the numbers needed to set the year.  If there are other numbers in the directory path, you could CD to the parent directory of the one containing the year numbers and use the -r (-recurse) option.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).