ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Grouaaah on May 07, 2024, 10:55:25 AM

Title: Using exiftool to rename files associated to a specific filename
Post by: Grouaaah on May 07, 2024, 10:55:25 AM
Hello,

I am trying to use the "fix the size of restored JPEG files" function on GraphicConverter 12 on a large number of files.

While some functions add "(original)" at the end of the files, it is simple to just make a research and delete every (original) file if needed after the manipulation.
 

For the "fix the size of restored JPEG files", it is a bit different. After using it, about ~2k files are duplicated with the "(fix)" mention at the end of the filename. The file to delete is not the "(original)" one, it is the file with the real filename (for example, 20240705_123456.jpeg).

I am trying to find a way to delete all the files corresponding to the ones containing "(fix)" at the end easily, so I can then rename every "(fix)" file since they are the ones I want to keep...

Would you know a solution to do it with exiftool or another reliable method?

Thank you very much
Title: Re: Using exiftool to rename files associated to a specific filename
Post by: StarGeek on May 07, 2024, 11:06:49 AM
Exiftool doesn't delete files.

You could use it to move any matching files to another directory, though. Test it first, but it would be something like this
exiftool -if5 "$Filename~=/\(fix\)/i" -srcfile %d%-.5f.%e  "-Directory=/Move/Orig/Here/" /path/to/files/

This checks if the Filename contains "(fix)".  If it does, using the -srcfile option (https://exiftool.org/exiftool_pod.html#srcfile-FMT), it looks for a file with the same filename minus 5 characters from the end of the base filename (see the Advanced features section of the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut)).  It will then move that file to the directory listed after "-Directory=.
Title: Re: Using exiftool to rename files associated to a specific filename
Post by: Martin B. on May 07, 2024, 11:09:54 AM
If you simply renamed each "filename (fix)" file to "filename", wouldn't this overwrite each "filename" without having to delete it first?

A simple Perl or shell script would do the job, or I'm sure there are "renamer" programs available for free on the web. This solution depends on the operating system you are using.
Title: Re: Using exiftool to rename files associated to a specific filename
Post by: StarGeek on May 07, 2024, 12:30:32 PM
Quote from: Martin B. on May 07, 2024, 11:09:54 AMIf you simply renamed each "filename (fix)" file to "filename", wouldn't this overwrite each "filename" without having to delete it first?

It depends upon what is used. mv on the command line would overwrite it, depending upon the options used. And I think it can be used on Windows, Mac, and Linux.

And, as you say, there are a lot of renaming programs out there.