ExifTool Forum

ExifTool => Newbies => Topic started by: clem on December 29, 2019, 01:23:50 AM

Title: Recursive file extension renaming for large collections of files
Post by: clem on December 29, 2019, 01:23:50 AM
This topic is pretty close to what I'd like to do ... but not quite.

https://exiftool.org/forum/index.php?topic=10491.0 (https://exiftool.org/forum/index.php?topic=10491.0)

I'd like to dive deep into a series of folders with many many files (all without extensions) and get exiftool to add the missing extensions to everything it can identify. Bonus to rename the files in YYY-MM-DD-HHMMSS.extension if it is an image or video file. [not all files are images or videos... some are hidden .tar files etc.]

so far I've been using iterations of

exiftool -ext '*' -if '$FileType=~/JPEG/i' '-Directory<./%f.$FileTypeExtension' -r DIR/
exiftool -ext '*' -if '$FileType=~/MOV/i' '-Directory<./%f.$FileTypeExtension' -r DIR/
exiftool -ext '*' -if '$FileType=~/HEIC/i' '-Directory<./%f.$FileTypeExtension' -r DIR/

but considering the variety of files I'm dealing with, that might be a bit tedious.

thank you!
Title: Re: Recursive file extension renaming for large collections of files
Post by: StarGeek on December 29, 2019, 01:45:02 AM
In that topic the the poster was looking for jpegs in particular.  If you want exiftool to add extensions to anything it can identify, then just remove the -if statement.  Also take note that I messed up the first attempts and it should be Filename as listed in the last post in that thread.
exiftool -ext '*' '-FileName<%f.$FileTypeExtension' -r DIR/
Title: Re: Recursive file extension renaming for large collections of files
Post by: Phil Harvey on December 29, 2019, 07:59:45 AM
And here is your bonus command:

exiftool -ext '*' '-FileName<%f.$FileTypeExtension' '-FileName<${CreateDate;$self->GetValue("MIMEType")=~/image|video/ or undef $_}.$FileTypeExtension' -r -d %Y-%m-%d-%H%M%S%%-c DIR

- Phil
Title: Re: Recursive file extension renaming for large collections of files
Post by: clem on December 30, 2019, 01:05:05 PM
Thank you very much to both of you. :-) Now to let the 'pooter do the hard work of diving through all the files... :-)

thank you,