Trying to edit a large number of files quickly...

Started by Fox, September 28, 2012, 11:47:09 AM

Previous topic - Next topic

Phil Harvey

Quote from: Fox on February 07, 2013, 05:18:41 PM
What about the rating (generally 1 to 5) or the tags? I tried adding -xmp-xmp:Rating and -xmp-dc:subject to the command line but it didn't do anything. It did correctly update the date for the files that had the date.

Where is the rating stored.  You can copy it from anywhere to anywhere you want.  See the -tagsFromFile option documentation for more information.

Quote1. is it possible to have it go recursively? It only worked on the main directory. (the routine I posted above will work recursively)

Yes.  Add the -r option.

Quote2. not sure how it happened i have a bunch of .modd files named basename.JPG.modd instead of basename.modd and it can't parse those it says "Warning: Error opening file - c:/path/to/basename.modd" in my code I just gave it a -fixModd flag that fixed the file names to basename.modd not sure if you could have it either read those files or an option to rename them maybe? I certainly didn't create them by hand, no idea how they got that way.

You can process these with another command.  See the -tagsfromfile documentation.

QuoteUnrelated to this I was trying to pass the date in and I had the date in the wrong format I originally had -DateTimeOriginal"YYYY,M,DD, HH,MM,SS' then "YYYY:M:DD HH:MM:SS" once I changed it to MM it worked, but I only got the error message when I only tried to edit the date, if I tried to do one of the 2 tags above with it, it would update the file with that information, but not the date and did not print any error message that I could find. (so I guess what I'm saying is if you just pass it 1 bad set of inputs exiftool gives you a nice error message but if you pass a good flag and a bad flag it updates the file will the good flag and ignores the bad flag and no error/warning message - would be nice to get some sort of warning with the bad flag)

Try adding -v2 if you want more messages. :)

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

Fox

Ok I read through the documentation a couple times.

The -r works great thank you!  :)

Changing the %d%f.modd to %d%f.jpg.modd got the extra files but that seems to need 2 passes (not a big deal, not sure if there's a wild card syntax that would work?) (I tried %d%f[.jpg]?.modd (and a couple variants) but none seemed to work. I think [.jpg]? gives 0 or 1 instances of the .jpg string for perl regex.

Not specifying any tags picked up all the ratings too, but not the labels any ideas there? (although without the reference tabels I'm guessing I'd get than encoded string).

regarding the -v2 that definitely gave error messages, so handy to know. I did notice some weird behavior when  I passed in some string it put nothing in other strings it put the wrong date in. -DateTimeOriginal"1977,4,10 01,01,01" came out as 10/1/1977 which i found to be strange (I am passing the correct date now, so its not an issue to me just letting you know it seems to parse the date incorrect sometimes).

Thanks so much for your help and supporting this tool.  :)

Phil Harvey

#17
Quote from: Fox on February 08, 2013, 10:26:21 AM
Changing the %d%f.modd to %d%f.jpg.modd got the extra files but that seems to need 2 passes (not a big deal, not sure if there's a wild card syntax that would work?)

No, 2 passes are required here.

QuoteNot specifying any tags picked up all the ratings too, but not the labels any ideas there? (although without the reference tabels I'm guessing I'd get than encoded string).

I can't help much without even knowing the tag names.  If you posted your MODD file it would help.

QuoteI did notice some weird behavior when  I passed in some string it put nothing in other strings it put the wrong date in. -DateTimeOriginal"1977,4,10 01,01,01" came out as 10/1/1977

Yes.  The date/time parsing will ignore an entry with only one digit.  The reason is that ExifTool will accept dates like 19770410010101, so it needs to look for a specific number of digits in each field.  This is explained in FAQ number 5.

QuoteThanks so much for your help and supporting this tool.  :)

You're welcome. :)

- Phil

Edit:  I just thought of a technique that I could use for date/time parsing that would support single-digit values as well as undelimited date/time strings.  I'll test it and if things work out maybe the next ExifTool version will be able to handle these.
...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 ($).

Fox

My modd file is this (its all on one line I tried to make it a little more readable here):

<?xml version="1.0" encoding="utf-8"?>
<plist version="1.0">
<dict>
<key>MetaDataList</key>
<array>
<dict>
<key>DateTimeOriginal</key>
<real>31064.884537037036000</real>
<key>FavoriteList</key>
<array/>
<key>LabelList</key>
<array>
<string>{5A932D96-EE43-4618-8EE8-DA9F5AFC3079}</string>
<string>{5802F031-759E-4DEB-AFED-CECAA7FCC926}</string>
</array>
<key>Rating</key>
<integer>3</integer>
</dict>
</array>
<key>XMLFileType</key>
<string>ModdXML</string>
</dict>
</plist>


I have a file called FilterTree.xml which has this in it:

<dict>
<key>DisplayName</key>
<string>Family</string>
<key>IconId</key>
<integer>131329</integer>
<key>IdName</key>
<string>{5A932D96-EE43-4618-8EE8-DA9F5AFC3079}</string>
<key>IdNumber</key>
<integer>102</integer>
<key>_Children</key>
<array>
<dict>
<key>DisplayName</key>
<string>Steve</string>
<key>IconId</key>
<integer>131331</integer>
<key>IdName</key>
<string>{5802F031-759E-4DEB-AFED-CECAA7FCC926}</string>
<key>IdNumber</key>
<integer>104</integer>
<key>_Children</key><array/>
</dict>


The whole file is much larger but the 5A code should map to "Family" and the 58 code should map to Steve. (basically mapping the IdName to the DisplayName.) I'm guessing you'd need the xref file for this.

Phil Harvey

OK, so ExifTool extracts this from your MODD file:

> exiftool ~/Desktop/t.modd -plist:all
Date/Time Original              : 1985:01:17 21:13:44
Favorite List                   :
Label List                      : {5A932D96-EE43-4618-8EE8-DA9F5AFC3079}, {5802F031-759E-4DEB-AFED-CECAA7FCC926}
Rating                          : 3
XML File Type                   : ModdXML


The DateTimeOrginal and Rating look useful, but as you said the LabelList contains useless GUIDs.  ExifTool won't look up these GUID's up for you in FilterTree.xml.

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

Fox

Ok I finally got everything working on my PC at home and updated my whole library correctly.

I'll just post an idiots guide to using this in case anyone anywhere is trying to do the exact same thing.

1. Download perl onto your system, recommend strawberry perl: http://learn.perl.org/installing/windows.html
2. get Date::Calc after doing the above from the command prompt type "cpan Date::Calc"
3. get exiftool install in C:\exiftool http://www.exiftool.org/
4. download getTagInfo.pl (wrapper for above looking for executable in C:\exiftool\exiftool )
http://code.google.com/p/gettaginfo-exiftool/downloads/detail?name=getTagInfo.pl&can=2&q=
Recommend installing in exiftool folder.
5. cd to folder with getTagInfo.pl  in it (cd C:\exiftool)
6. open command prompt type: "perl getTagInfo.pl -startDir C:\path\to\pics -filterTree C:\path\to\FilterTree.xml" can optionally add:

-fixFileExt if you have extra .jpg. in your file names (any file type it will change, but meant for jpg or modd files to reduce names, can cause issues if you have jpg in you basename as well as extra .jpg. in your extentions. ie <file>JPG.modd instead of <file>.modd 

-owOrg file to not get _original versions of all your pictures (recommend to back them up in a different directory structure/hard drive before running this).   

-debug will print more info to the log file (log file should appear in run directory getTagInfo.log)

Put any paths with spaces in double quotes.

The exact command I ran, and depending on user ID and whether you put your pictures in a public/person space on your windows  7 pc is:
perl getTagInfo.pl -startDir C:\Users\Public\Pictures -filterTree "C:\Users\Steve\My Documents\Sony PMB\FilterTree.xml" -fixFileExt -owOrg -debug


Additionally I only set this up to work on jpg files. So if you have gifs or png or something it will skip those. It reports the # of modd files found and the #of files edited. These should match. I had 10 more modd files than files edited but this was due to a couple of modd files that had no picture associated with them (no idea how this happened - possibly got manually renamed/deleted). and it skipped the handful of non-jpg files. It took about 2 hrs to update 13630 files on my PC.

If anyone out there is interested in using it my email is in the comments at the top of the program. I highly recommend the debug mode although it can generate a rather large text file (it will generate about 4-5 lines per picture - so mine was ~68k lines and 5MB of text) but I would need it to debug if any thing does not appear to work. Please back up your files before use.