FileTypeExtension not being applied to filename

Started by dRuEFFECT, November 21, 2024, 01:34:25 AM

Previous topic - Next topic

dRuEFFECT

I was trying to update -AllDates on a bunch of files and got the dreaded "Error: Not a valid PNG (looks more like a JPEG)"

It doesn't tell me which files have errored, so I want to broadly update files. I found several different commands I can use to do so, but then they aren't working right. I provided a screenshot of the commands and results.


First I'm showing the target folder with a single png file, 14.png

Next I'm making sure I isolate files with png extension, and print the FileType and FileTypeExtension, shows PNG and png as expected
./exiftool -ext png -filetype -filetypeextension /mnt/user/metadata/Andrew/time\ capsule/six\ flags\ pix/
I test an if statement for checking if the file is a JPEG, that fails as expected.
./exiftool -ext png -if "$filetype eq 'JPEG'" "-filename=%f.jpg" /mnt/user/metadata/Andrew/time\ capsule/six\ flags\ pix/
Then I test it again checking for PNG, but this also fails. Weird.
./exiftool -ext png -if "$filetype eq 'PNG'" "-filename=%f.png" /mnt/user/metadata/Andrew/time\ capsule/six\ flags\ pix/
So I try out another approach I found that doesn't use if statement, just applying the FileTypeExtension tag it has and it should just rename it to the same filename it already is... except it doesn't.
./exiftool -ext png "-filename=%f.$fileTypeExtension" /mnt/user/metadata/Andrew/time\ capsule/six\ flags\ pix/
I list the files in the folder again and see it renamed it to "14." without the extension.

So I have to manually mv the file to put the extension back on.

I don't think I'm doing anything wrong here. What gives?

Screenshot 2024-11-21 011301.png

StarGeek

Swap the quotes. You're on Linux, so a dollar sign surrounded by double quotes is a shell variable, not an exiftool tag.

As an example, you would use this
-if '$filetype eq "PNG" '
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype