ExifTool Forum

ExifTool => Newbies => Topic started by: jhimmy dingo on December 14, 2023, 01:29:32 AM

Title: How to rename files, only deleting the last four characters of the filename?
Post by: jhimmy dingo on December 14, 2023, 01:29:32 AM
Another company's server exports MOV video files and JSON sidecar metadata files in an odd format that I need to batch rename.

I receive the files and they're named something like this:
QuoteFile1.mov.mov, File1.mov.json

This naming error, where the file has an extra ".mov" at the end of the filename but before the extension, is causing me issues. I need to delete that extra ".mov" in a batch renaming process. The rest of the file name needs to stay the same. Any ideas?
Title: Re: How to rename files, only deleting the last four characters of the filename?
Post by: Phil Harvey on December 14, 2023, 07:42:09 AM
exiftool "-filename<${filename;s(\.mov\.)(.)}" -ext mov -ext json DIR

- Phil
Title: Re: How to rename files, only deleting the last four characters of the filename?
Post by: jhimmy dingo on December 14, 2023, 09:55:36 AM
Phil, I hope you get paid for this product and service--this worked perfectly after I changed out the double quotes for single quotes on a Mac.

Interestingly, after testing, I've found that your code works perfectly on MOV files that I've created locally; AND the code STILL works with the MOV files created by the outside company, however, with their files I get the error:
Warning: Truncated '\xa0/\x88\xf7' data - /file/path/filename.mov.mov

Which makes me think there's still SOMETHING wrong with the MOV files I'm receiving... BUT the code still works and removes the additional ".mov" in the name.

Thanks again!
Title: Re: How to rename files, only deleting the last four characters of the filename?
Post by: Phil Harvey on December 14, 2023, 10:05:01 AM
That error likely indicates there is some proprietary trailer added to the end of the file.  I've seen this before in MOV/MP4 video files.

Quote from: jhimmy dingo on December 14, 2023, 09:55:36 AMPhil, I hope you get paid for this product and service

Exiftool is free. :)

- Phil