Hello.
I'm trying to change the FileModifyDate based in the FileName, but only if they are different. But my code is not working... ::)
For example, this 8 files already have the FileName synchronized to the FileModifyDate
$ ls -lT
total 134078
-rw-r--r-- 1 user group 304216 25 abr 14:13:36 2009 2009-04-25 14.13.36-1.avi
-rw-r--r-- 1 user group 304216 25 abr 14:13:36 2009 2009-04-25 14.13.36.avi
-rw-r--r-- 1 user group 15346696 2 oct 12:37:19 2010 2010-10-02 12.37.19.dng
-rw-r--r-- 1 user group 27328928 16 oct 12:44:02 2010 2010-10-16 12.44.02.dng
-rw-r--r-- 1 user group 11003879 14 ene 17:45:32 2018 2018-01-14 17.45.32-1.nef
-rw-r--r-- 1 user group 11003879 14 ene 17:45:32 2018 2018-01-14 17.45.32.nef
-rw-r--r-- 1 user group 1676995 20 feb 22:13:19 2019 2019-02-20 22.13.19-1.jpg
-rw-r--r-- 1 user group 1676995 20 feb 22:13:19 2019 2019-02-20 22.13.19.jpg
But this code is not working as expected (that is, only change FileModifyDate if it's different to FileName):
$ exiftool -ext '*' '-FileModifyDate<FileName' -if '$FileModifyDate ne $FileName' .
Warning: [minor] Bad IDC_IFD SubDirectory start - ./2010-10-16 12.44.02.dng
1 directories scanned
8 image files updated
Ah, one more question please, if I don't expecify -ext '*' then the avi file is not processed, why?
$ exiftool '-FileModifyDate<FileName' -if '$FileModifyDate ne $FileName' .
Warning: [minor] Bad IDC_IFD SubDirectory start - ./2010-10-16 12.44.02.dng
1 directories scanned
6 image files updated
This is using macOS.
Thank you very much in advance!
Quote from: vicmarto on February 23, 2019, 09:58:43 PM
-rw-r--r-- 1 user group 304216 25 abr 14:13:36 2009 2009-04-25 14.13.36-1.avi
File names like this will always be not equal to a date/time because they aren't formatted the same way (plus they have an extension). I can show you how to do this, but it will be a bit complex and I don't have time at the moment. I'll try to do this tomorrow.
QuoteAh, one more question please, if I don't expecify -ext '*' then the avi file is not processed, why?
This is FAQ 16 (https://exiftool.org/faq.html#Q16).
- Phil
Quote from: vicmarto on February 23, 2019, 09:58:43 PM
$ exiftool -ext '*' '-FileModifyDate<FileName' -if '$FileModifyDate ne $FileName' .
Warning: [minor] Bad IDC_IFD SubDirectory start - ./2010-10-16 12.44.02.dng
1 directories scanned
8 image files updated
ne will return true if the two things being compared are not equal. Exiftool will return a date in the format of
YYYY:MM:DD HH:mm:ss. Unless the file name exactly matches that, it will always not be equal. You're comparing
2009:04:25 14:13:36 to
2009-04-25 14.13.36-1.avi, obviously not equal. What you want to do is format the numbers in the filename to the same as what is returned from
FileModifyDate, or something along those lines.
Try this. I haven't tested it but it might do what you want.
exiftool -ext '*' '-FileModifyDate<FileName' -if '${FileModifyDate;tr/0-9//cd} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' .The
tr/0-9//cd sets up a translate function. It creates a set of all digits
0-9, complements the set (the
c option) so that it matches anything not a digit, and then deletes them (the
d option). Thus, you're left with nothing but numbers. For the filename, there's a follow up that drops any numbers after the first 14. So, for example, file
2009-04-25 14.13.36-1.avi would end up comparing "20090425141336" to "20090425141336" (having dropped the trailing "1").
Thank you very much to both!
And sorry Phil for not reading the FAQ before ;D
@StarGeek: Brilliant! What you propose should work, but unfortunately:
$ exiftool -ext '*' '-FileModifyDate<FileName' -if '${FileModifyDate;tr/0-9//cd} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' .
Warning: [minor] Bad IDC_IFD SubDirectory start - /mnt/zfast/Users/vicmarto/Pictures/[P]/2010-10-16 12.44.02.dng
1 directories scanned
8 image files updated
$ ls -lT
total 134078
-rw-r--r-- 1 user group 304216 25 abr 14:13:36 2009 2009-04-25 14.13.36-1.avi
-rw-r--r-- 1 user group 304216 25 abr 14:13:36 2009 2009-04-25 14.13.36.avi
-rw-r--r-- 1 user group 15346696 2 oct 12:37:19 2010 2010-10-02 12.37.19.dng
-rw-r--r-- 1 user group 27328928 16 oct 12:44:02 2010 2010-10-16 12.44.02.dng
-rw-r--r-- 1 user group 11003879 14 ene 17:45:32 2018 2018-01-14 17.45.32-1.nef
-rw-r--r-- 1 user group 11003879 14 ene 17:45:32 2018 2018-01-14 17.45.32.nef
-rw-r--r-- 1 user group 1676995 20 feb 22:13:19 2019 2019-02-20 22.13.19-1.jpg
-rw-r--r-- 1 user group 1676995 20 feb 22:13:19 2019 2019-02-20 22.13.19.jpg
What is the output of
exiftool -ext '*' -p '${FileModifyDate;tr/0-9//cd} ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' .
Thanks StarGeek for your help:
$ exiftool -ext '*' -p '${FileModifyDate;tr/0-9//cd} ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' .
200904251413360900 20090425141336
201010021237190900 20101002123719
201902202213190900 20190220221319
201010161244020900 20101016124402
Warning: Bad IDC_IFD SubDirectory start - ./2010-10-16 12.44.02.dng
201801141745320900 20180114174532
200212272214320900 20021227221432
200904251413360900 20090425141336
201801141745320900 20180114174532
201902202213190900 20190220221319
Hmm... A trailing 0900 in each of the FileModifyDate tags. I don't know enough about Mac to know why but the solution is the same as removing extra trailing numbers from the filename
Try
exiftool -ext '*' '-FileModifyDate<FileName' -if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' .
Phil might be able to come up with something better tomorrow. Sorry, I'll be heading to bed in a few minutes.
Thanks StarGeek!! This worked perfectly.
And yes, I'm agree, macOS sometimes do odd things ;D
The trailing digits in FileModifyDate where the time zone.
- Phil
Quote from: Phil Harvey on February 24, 2019, 07:41:48 AM
The trailing digits in FileModifyDate where the time zone.
And there's my Homer D'oh moment of the day.
Quote from: StarGeek on February 24, 2019, 12:18:37 PM
Quote from: Phil Harvey on February 24, 2019, 07:41:48 AM
The trailing digits in FileModifyDate where the time zone.
And there's my Homer D'oh moment of the day.
Hahhahaa, yes! Me too. Thanks to both! Really! ;D
Quote from: StarGeek on February 24, 2019, 01:06:12 AM
Hmm... A trailing 0900 in each of the FileModifyDate tags. I don't know enough about Mac to know why but the solution is the same as removing extra trailing numbers from the filename
Try
exiftool -ext '*' '-FileModifyDate<FileName' -if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' .
Phil might be able to come up with something better tomorrow. Sorry, I'll be heading to bed in a few minutes.
Arrrrgggghhh!! Sorry StarGeek, can't understand why... Your code was working perfectly when integrated in my ExifTool order, this one:
exiftool \
-d '%Y-%m-%d %H.%M.%S' -ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}%-c.${FileTypeExtension}' '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}.${SubSecTime;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${CreateDate}.${SubSecTimeDigitized;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${DateTimeOriginal}.${SubSecTimeOriginal;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'png' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' '-FileName<${DateCreated}%-c.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'avi' \
-api largefilesupport=1 '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'mov' -ext 'mp4' \
-api largefilesupport=1 '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${CreationDate}%-c.${FileTypeExtension}' \
-execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
-if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' '-FileModifyDate<FileName' \
-common_args -r -overwrite_original \
.
BUT, when I hardcore the desired output directory into the
-d option (to make a shell script) instead of
., don't work anymore! The files do not get the correct
FileModifyDate!!!:
exiftool \
-d '/Users/user/Pictures/%Y-%m-%d %H.%M.%S' -ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}%-c.${FileTypeExtension}' '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}.${SubSecTime;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${CreateDate}.${SubSecTimeDigitized;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${DateTimeOriginal}.${SubSecTimeOriginal;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
-execute \
-d '/Users/user/Pictures/Screenshots/%Y-%m-%d %H.%M.%S' -ext 'png' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' '-FileName<${DateCreated}%-c.${FileTypeExtension}' \
-execute \
-d '/Users/user/Pictures/%Y-%m-%d %H.%M.%S' -ext 'avi' \
-api largefilesupport=1 '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
-execute \
-d '/Users/user/Pictures/%Y-%m-%d %H.%M.%S' -ext 'mov' -ext 'mp4' \
-api largefilesupport=1 '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${CreationDate}%-c.${FileTypeExtension}' \
-execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
-if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' '-FileModifyDate<FileName' \
-common_args -r -overwrite_original \
.
All is the same except the
-d option. Please, help... Thanks!
Do you mean that the files moved to that directory have the wrong FileModifyDate. I'm assuming that the file name is correct. If you move a file to a different filesystem then the FileModifyDate will change unless you add -P to the command.
- Phil
Yes, I know, but in this case and thank to the code from StarGeek:
-if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' '-FileModifyDate<FileName'
The file must sync its FileModifyDate with it's FileName (instead of the original FileModifyDate, because now the FileModifyDate of my photos is a totally mess!)
I'm afraid that I'm a bit lost here. When you say the FileModifyDate of your photos is a total mess, can you give an example for one file?
- Phil
Quote from: Phil Harvey on February 27, 2019, 10:03:14 AM
I'm afraid that I'm a bit lost here. When you say the FileModifyDate of your photos is a total mess, can you give an example for one file?
- Phil
This one, for example:
$ exiftool -s -time:all -a -G0:1 2002-12-27\ 22.14.32-1.jpg
[File:System] FileModifyDate : 1990:01:01 00:00:00+09:00
[File:System] FileAccessDate : 1990:01:01 00:00:00+09:00
[File:System] FileInodeChangeDate : 1990:01:01 00:00:00+09:00
[EXIF:IFD0] ModifyDate : 2002:12:27 22:14:32
[EXIF:ExifIFD] DateTimeOriginal : 2002:12:27 22:14:32
[FlashPix] ExtensionCreateDate : 0
[FlashPix] ExtensionModifyDate : 0
Ah. The problem is that your last command needs to set the FileModifyDate for files in the destination directory, not the source directory. So you can't use "." as a directory name in the command with -if either. See my other post (https://exiftool.org/forum/index.php/topic,9918.msg51607.html#msg51607) when I move this out of the -common_args, and change the "." for this command only.
- Phil
Thanks Phil, let's continue in the other topic, now they are related.