Main Menu

filename>alldates

Started by sebastian84, April 19, 2018, 12:32:20 AM

Previous topic - Next topic

sebastian84

Hi, im a new user of the tool and have been trying to figure out how to do the following.

I have Nikon D3100 jpg's with empty exifs for date taken and wrong for the other dates (modified, created, etc). I do have the original taken date in the filenames in the following format.

04092015134624.jpg being DDMMYYYYHHMM??

Can you help me writing the command line so i can overwrite alldates with this date? I have tried many combinations unsucsessfully. Shall i renarange the filenames to other format first?

Thanks
Sebastian

Hayo Baan

With the advanced formatting feature you can rearrange the order of the date elements and set the dates directly from the filename:
exiftool '-alldates<${filename;s/(\d{2})(\d{2})(\d{4})(\d{6})/$3:$2:$1 $4/}' DIRorFILE
(on Windows, use double quotes instead of single quotes).
If you need to modify more date/time tags (despite its name, alldates isn't all date/time tags), just add them (replacing alldates with the name of the tag).
If this works and you don't want exiftool to create the copy, add the -overwrite_original option to the command, add -P to maintain the original file modification date.
Hayo Baan – Photography
Web: www.hayobaan.nl

StarGeek

If your filename format was YearMonthDay, it would be as simple as "-alldates<filename" (see FAQ 5) but since you have DayMonthYear, the Day and Year numbers need to be swapped. 

Try this (test it first, of course):
exiftool "-alldates<${filename;s/^(\d\d)(\d\d)(\d{4})/$3$2$1/}"
* 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).

sebastian84

Quote from: Hayo Baan on April 19, 2018, 02:38:47 AM
With the advanced formatting feature you can rearrange the order of the date elements and set the dates directly from the filename:
exiftool '-alldates<${filename;s/(\d{2})(\d{2})(\d{4})(\d{6})/$3:$2:$1 $4/}' DIRorFILE
(on Windows, use double quotes instead of single quotes).
If you need to modify more date/time tags (despite its name, alldates isn't all date/time tags), just add them (replacing alldates with the name of the tag).
If this works and you don't want exiftool to create the copy, add the -overwrite_original option to the command, add -P to maintain the original file modification date.

worked like a charm, thanks! i would have never got it by myself  :-*

Quote from: StarGeek on April 19, 2018, 02:41:03 AM
If your filename format was YearMonthDay, it would be as simple as "-alldates<filename" (see FAQ 5) but since you have DayMonthYear, the Day and Year numbers need to be swapped. 

Try this (test it first, of course):
exiftool "-alldates<${filename;s/^(\d\d)(\d\d)(\d{4})/$3$2$1/}"

thanks StarGeek ive read FAQ but my formatting was very specific. Ive tried unsucessfully to use the simple command but didnt work. Used it with success in the past!

Phil Harvey

There is another way that I don't think has been mentioned previously on this forum:

exiftool "-alldates<filename" -d "%d%m%Y%H%M%S" DIR

The -d option has worked in reverse since ExifTool 10.29, but it isn't very flexible in its parsing of date/time strings so it isn't very useful.  However, in this case the filenames are consistent and simple enough to use this feature.

- 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 ($).

StarGeek

I was going to suggest that at first (but messed up the date formatting), but when I try that now, I get an error and nothing is written.

ver 10.93
C:\>exiftool -P -overwrite_original "-alldates<filename" -d "%d%m%Y%H%M%S" "Y:\!temp\y\04092015134624.jpg"
Warning: garbage at end of string in strptime: .jpg in ExifIFD:DateTimeOriginal (PrintConvInv) - Y:/!temp/y/04092015134624.jpg
Warning: No writable tags set from Y:/!temp/y/04092015134624.jpg
    0 image files updated
    1 image files unchanged
* 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).

Phil Harvey

OK, so your strptime is pickier than mine.  Does it work with -d "%d%m%Y%H%M%S.jpg" ?

- 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 ($).

StarGeek

* 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).

sebastian84

Thanks for the suggestions guys, and thanks for the tool Phill.

Im uploading all my old pre smartphone era travel pics to google photos. Mostly they are from two sources (two digital cameras, old smartphone and DSLR, etc).

Im not having much trouble arranging and sorting photo dates except from what i asked here. For location im using geosetter with its simple GUI and its working fine for massive single locations and time zones.

After running proposed solutions for DSLR pictures i see that almost all dates where overun by filename, and when check on windows every date is the one taken from filename.  But when i copy them to my google pixel to upload them to google photos, it classifies them as being taken two days ago on 17/04/2018.

Upon further inspection using geosetter exif panel and sorting columns i can see this (see atachment):

Google photos must be giving priority to GPS date over all the rest.

Can you help me overwrite just this command? Is it even possible or shall al wipe all gps data and then copy it again using geosetter.

For some reason, when i set city geolocation to the set of pictures that contained correct date info in exif data GPS date is the same as the correct date taken data and not 17/04/2018. It seems as geosetter copies that date from avaialble data and if unavailable just stamps "today's" date.

I hope i made myself clear and thanks again for all the quick help



Phil Harvey

Try this to set the GPS times after writing AllDates:

exiftool "-gpsdatestamp<createdate" "-gpstimestamp<createdate" DIR

This should work as a separate command, but writing GPSDateStamp and GPSTimeStamp require properly-formatted date/time strings, so your advanced formatting expression would have to be tweaked if you wanted to write them together with AllDates in one command.

- Phil

P.S. Can you suggest Spanish translations for "GPS Date/Time" and "Date/Time Digitized"?  I'll add these translations to ExifTool (and they'll show up in GeoSetter when it updates to the new ExifTool version).

...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 ($).

sebastian84

Thanks Phill i will save this thread for the unlikely case i come across new pictures with the same file format. That did the trick i will now see if google photos likes new exif data and sort pictures properly.

"GPS Date/Time": Fecha y Hora GPS
"Date/Time Digitized": Fecha y Hora Digital

PS: if you need help with spanish translations just PM me in the future and i will gladly help. I will activate email notifications if available.

Phil Harvey

...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 ($).