Rename file extension based on metadata

Started by wk002, May 12, 2021, 04:27:25 PM

Previous topic - Next topic

wk002

I want to rename all my photos using the date and time but I think I may have some photos that have the extension messed up in the filename. Is there a way to rename the files like in the documentation examples but use something from the metadata to correct file extensions? If I am reading the documentation right .%%e uses the existing file extension correct?

For instance in the past I may have accidentally renamed files with no extension. Now I have no idea if the file is damaged or just won't open because of a missing extension.


exiftool "-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" DIR

StarGeek

Try
exiftool "-Filename<$CreateDate.$FileTypeExtension" -d "%Y%m%d_%H%M%S" DIR

This won't process files that don't have an extension but you can add -ext "*" to process them (see FAQ #16).  I wouldn't suggest doing that for a directory that might have other file types that you don't want renamed.
* 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).

wk002

I will try that command. What about -tagsfromfile? I was looking through the documentation and found that switch. Though I am not totally sure that is a switch. 

StarGeek

From the docs on the -TagsFromFile option
     As a convenience, -tagsFromFile @ is assumed for any redirected tags which are specified without a prior -tagsFromFile option.

When you're copying one tag into another in the same file, then -TagsFromFile isn't needed.
* 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).