File renaming

Started by glenbodie, October 28, 2016, 07:07:57 PM

Previous topic - Next topic

glenbodie

I have a directory with subdirectories full of JPG. A previous application has renamed the files so that there are no spaces internal to the filename. Thus "Start of Race.jpg" became "Start+of+Race.jpg". I can't easily go back to the old names for 29,000 images. I am adding some keyword tags to the JPG files and I was wondering if I could rename them as they were being processed.

My command line at the moment is:
exiftool -m -r -P -fixbase -o "I:\OutputDIR\%-1:D\%f.%e" -csv=AddTags.csv "I:\InputDIR" 2>errors.txt

And I'm wondering if the -Filename with a Perl translation string like this would work:
-Filename{t/ /+/}
or maybe in the new output names
\%f{t/ /+/}.%e

Phil Harvey

Try this:

exiftool -m -r -P -fixbase -o . "-filename<I:\OutputDIR\%-1:D\${filename;tr/+/ /}" -csv=AddTags.csv "I:\InputDIR" 2>errors.txt

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

glenbodie

Great Phil, that looks like the file renames are working just fine. I guess I was sorta close but it would have taken me a lot of experimentation to get the syntax just right <grin> so thanks.

Next step in my updating of these 29,000 files is to correct a few errors that EXIFtool is reporting. Maybe you can help with some command line args that will fix things as it goes through them all. The best result for me would be that if it cannot repair the problem, then just copy the file as is from the source to destination directory.

I'm getting a big pile of "Error: Error reading StripOffsets data in IFD1". Is there something I can do to make it either fix this error or ignore it and still get a file in the destination directory?

I do have -m in the command line but do I need to be concerned about any of the warnings I am getting? As far as I know all the image data is good, we can see the pictures as expected, so I think all of this relates to metadata which I COULD lose if I had to and then maybe manually recreate some of the key data.

You'll see I had -fixbase in the command line because some of the images reported errors in the MakerNotes, and it seems to have helped but I still get a few
Warning: Error rebuilding maker notes (may be corrupt)
Warning: Can't read MakerNotes data. Ignored.

And a few other Warnings. Should I be concerned about these?
Warning: Bad NikonScanIFD SubDirectory start
Warning: Bad NikonScanIFD directory
Warning: Invalid original decision data
Warning: Invalid CanonCameraSettings data
Warning: Unrecognized CameraInfo7D firmware version
Warning: Invalid EXIF text encoding for UserComment
Warning: Bad PreviewIFD directory
Warning: File format error
Error: Format error in file

At the end of a run, the program spit out:
  989 directories scanned
  987 directories created
28738 image files created
    0 image files updated
  401 files weren't updated due to errors

Phil Harvey

Quote from: glenbodie on October 29, 2016, 04:44:39 PM
I'm getting a big pile of "Error: Error reading StripOffsets data in IFD1". Is there something I can do to make it either fix this error or ignore it and still get a file in the destination directory?

This is a major problem, and ExifTool can not be used to fix this unless it is a JPEG, which shouldn't have StripOffsets in the first place.  If it is a JPEG, you can read FAQ 20 for how to fix it.  Otherwise, you can't write this file with ExifTool (although you can still use ExifTool to do the renaming). 

QuoteI do have -m in the command line but do I need to be concerned about any of the warnings I am getting?

It depends on how important the maker note metadata is to you.  Typically it is only the makernote information that may be lost if you use -m.  The maker notes are not crutial for JPEG images, but for RAW image formats I would take these warnings more seriously.

QuoteWarning: Bad NikonScanIFD SubDirectory start
Warning: Bad NikonScanIFD directory

There is no useful information in this IFD, so don't worry about this.

QuoteWarning: Invalid original decision data
Warning: Invalid CanonCameraSettings data
Warning: Unrecognized CameraInfo7D firmware version

Likely something else edited these images and the canon information has got corrupted.  See my comments about maker notes above.

QuoteWarning: Invalid EXIF text encoding for UserComment

Bad software wrote this metadata.

QuoteWarning: Bad PreviewIFD directory

You may have lost the preview image.

QuoteWarning: File format error
Error: Format error in file

These are more serious and may indicate a corrupted image.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

glenbodie

Thanks. They are all JPG and I don't care about the MakerNotes.
I'll try the FAQ20 method to fix those with the bad StripOffsets in IFD1.

Warning: Invalid EXIF text encoding for UserComment - can I use EXIFtool to delete and rewrite the metadata so that there are no more complaints?

Warning: Bad PreviewIFD directory - think it will work if I load them in to an image editor, make a trivial change and write the image to a new file?

Warning: File format error and Error: Format error in file - I think there was only one of these and I may have lost that image, I'll check, might be recoverable from other sources.

There were 29,140 JPGs in my source directories. EXIFtool says it created 28,738 files and there were 401 not updated due to errors. So that leave 1 file unaccounted for, and I expect that is the one with the file format error - sound likely? However, having 401 images not make it to the output directory is a problem. I need to do something to fix those or at least make sure EXIFtool tries to fix them or keeps them intact and moves them over to the output directory.

I can't even tell which ones those 401 were because I don't know which errors or warnings cause the file to get skipped. Of the different errors or warnings I had:
Error: Error reading StripOffsets data in IFD1 - 396
Error: Format error in file - 1
Error creating files or directories - 7 and I have fixed those
Warnings of various kinds - 98

See why I'm having trouble reconciling the error messages with the actions taken and the response needed from me?

StarGeek

Quote from: glenbodie on October 30, 2016, 02:38:52 AM
Warning: Invalid EXIF text encoding for UserComment - can I use EXIFtool to delete and rewrite the metadata so that there are no more complaints?

Unless you specifically added it, the usercomment probably doesn't have any useful data.  Take a look at it (exiftool -usercomment FILE) and then you can decide if you want to just delete it or recreate it.

QuoteWarning: Bad PreviewIFD directory - think it will work if I load them in to an image editor, make a trivial change and write the image to a new file?

That might recreate a thumbnail, but probably not a preview image. It would depend upon the program.  And it would be destructive to the image for no real gain.  You can live without a preview image but if you really want, you can load the image in an image editor, shrink it to the size of preview image you want, and then use exiftool to insert the smaller image as a preview into the original.
* 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

If there is any error then the file was not updated.  Warnings shouldn't cause the file to get skipped.  I think the PreviewIFD warning should be fixed by just writing the file with -m.  The UserComment warning will be fixed by writing that tag.

The one unaccounted file should be one that ExifTool didn't try reading.  Are you sure they are all ".jpg" files?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

glenbodie

With that FAQ20 process I fixed about 400 files, thanks. But I had to run the -F through the collection twice. The first time through it gave me this message
Warning: Not enough values specified (4 required) for ExifIFD:ComponentsConfiguration
but I just ran it again and there were no complaints.

Phil Harvey

Glad you straightened things out.

Quote from: glenbodie on October 30, 2016, 04:34:22 PM
Warning: Not enough values specified (4 required) for ExifIFD:ComponentsConfiguration

This error indicates that the ComponentsConfiguration wasn't written.  If so, then I think there should have been no errors in the file after the first pass.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).