IF date is blank, THEN do what??

Post any Bulk Rename Utility support requirements here. Open to all registered users.

IF date is blank, THEN do what??

Postby jomk » Sun Nov 03, 2013 10:34 pm

Hi - first posting, and just want to say Great Tool :)

I want to rename a large number of jpg files with the "Date Taken (Original)" field, in the format of %Y_%m_%d_%H%M%S and am using section(2)=remove and section(8) prefix, etc)

However, if this field is blank, then i get a file called " .jpg" :(

Is there any way I can say, If date field is blank, then use, say, Date Modified? Or a sequential number. Or ... ???


Also - i want to save the original file-name and cant see how to do that? ( Current plan would be to use exiftool -iptc:caption-abstract<filename *.jpg to move current filename into the IPTC field and then run BRU on all the files. Anyone done this before or got a better suggestion for me?

Also, Also - What do people do with the name.jpg_original files after they have successfully renamed? - this will double the current space for 17,000 files and 50Gb storage?

Thanks!
jomk
 
Posts: 3
Joined: Sun Nov 03, 2013 9:34 pm

No conditional processing for #2Remove

Postby truth » Mon Nov 04, 2013 12:09 pm

2Remove has no conditional processing (other than: if filename selected, it gets processed)
Since you're already using ExifTool, I'd create a batch similiar to:

exiftool -P -overwrite_original_in_place -iptc:caption-abstract^<filename *.jpg
exiftool -filename^<DateTimeOriginal -d %%Y_%%m_%%d_%%H%%M%%S%%%%-2c.%%%%e *.jpg
exiftool -if "not $DateTimeOriginal" -filename^<FileModifyDate -d %%Y_%%m_%%d_%%H%%M%%S%%%%-2c.%%%%e *.jpg

Line1 writes OrigFileName into IPTC's Caption (no copies created, all dates preserved)
Line2 renames .jpg's by their Exif:DateTimeOriginal (appending -## if needed to prevent dupes)
Line3 renames .jpg's IF no Exif:DateTimeOriginal exists (renames by FileModifyDate, appending -## if needed)

This assumes you prefer FileModifyDate as the 2nd-choice, when Exif:DateTimeOriginal doesnt exist
If thats not true, edit FileModifyDate, you can also add lines for 3rd/4th-choices using the same logic
Last edited by truth on Sat Nov 23, 2013 11:00 am, edited 1 time in total.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: IF date is blank, THEN do what??

Postby jomk » Mon Nov 11, 2013 2:39 pm

Truth, that's really helpful - once i'd got the hang of double %% and ^ in a batch file :)

If I want to set the DateTimeOriginal from FileModifyDate - is there any reason why this wont work?

exiftool -if "not $DateTimeOriginal" -DateTimeOriginal^<FileModifyDate -r -ext jpg -ext cr2 d:\test2 >oput1.txt

do i need EXIF: and FILE: qualifiers?

Also - FMD has an UTC offset - might this cause a problem?

I have tried with a few files and cant seem to get it to set the new DTO from the batch file. (PS i've tried a few times to put the -P option into the line too but the modify date gets changed to the current time. :(

THANKS!
jomk
 
Posts: 3
Joined: Sun Nov 03, 2013 9:34 pm

Re: IF date is blank, THEN do what??

Postby jomk » Mon Nov 11, 2013 11:25 pm

OK - so i seem to have cracked it! :D

Used this in a .bat file

exiftool -P -overwrite_original_in_place -r -ext cr2 -ext jpg -iptc:caption-abstract^<filename d:\testX >line1o.txt
exiftool -if "not $DateTimeOriginal" -filename^<FileModifyDate -d %%Y_%%m_%%d_%%H%%M%%%%-2c.%%%%e -r -P -overwrite_original -ext jpg -ext cr2 d:\testX >line2o.txt
exiftool -if "$DateTimeOriginal" -filename^<DateTimeOriginal -d %%Y_%%m_%%d_%%H%%M%%%%-2c.%%%%e -r -P -overwrite_original -ext jpg -ext cr2 d:\testX >line3o.txt
exiftool -if "not $DateTimeOriginal" -EXIF:DateTimeOriginal^<File:FileModifyDate -r -P -overwrite_original -ext jpg -ext cr2 d:\testX >line4o.txt

This is NOT elegant :), however it does this :- (for all files with ext JPG or CR2, in directory D:\testX and all its subdirectories)

line 1, Move current Filename into the IPTC field Caption-Abstract. This is for future reference, and is neat, because it appears in the Windows Explorer column 'Title' and can be viewed/added in the Details view of any Windows explorer page.
line 2, If there isnt a DateTimeOriginal (eg from scans or old jpgs) then set the Filename to be 2011_12_28_1706-cc.ext from the FileModifyDate (which is the best approximation to a useful date for the image)
line 3, If there IS a DateTimeOriginal, then set the Filename to be 2011_12_28_1706-cc.ext from theDateTimeOriginal (which is when the image was shot)
line 4, If there isnt a DateTimeOriginal, then set it to the FileDateModify (so now all my images have a 'Date Taken', visible in Windows explorer)

NB I output the results into a separate txt for for each line - eg line1o.txt

NB I haven't used the seconds part of the date for file naming, but i do have a 2 digit number if there are more than one image in a minute.

NB Now I'm hgetting the hang of this, I'm going to add lines to move the files into a 2011/2011_01_Jan type DIR structure! :) (50Gb of images from about 10+ years)

Thanks to all on this forum and on the ExifTool forum at QueensU for helping!

I do think that a really good GUI on front of this tool would get easy backing from VCs in SanFran becuase there is a HUGE need for this as the years go on, and Phil Harvey, you could make a lot of money.

J
jomk
 
Posts: 3
Joined: Sun Nov 03, 2013 9:34 pm

Using ExifTool?

Postby truth » Wed Nov 13, 2013 4:38 am

Sorry, didnt mean to abandon you, figured this was a done deal.
I wasnt aware you also had cr2's, so yes that needed adding.
Also, I just figured you'd add the DirPath or launch the .bat within the right Dir

Looking at your 4 batchlines (& disreguarding the .txt directing) I'd probably:
Line1: Leave as-is
Line3: Move to Line2, -IF is optional (since -filename auto-fails when DateTimeOrig doesnt exist)
Line2/4: Combine them into a final line, since they both rely on the same if condition

Hopefully, it might help with processing speed?
Sorry, I've only recently downloaded exiftool, so I'm still going though the help file.
Learning commands is one thing, but knowing what processes fastest is a whole different matter.
There is an ExifToolGUI v5.15 over at that forum, but I'm not familiar with it.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to BRU Support