fix_wrong_image_extensions is a filename fixer that fixes the extension of images saved with wrong/duplicate/no extensions
It fixes any of these (and not just for JPGs--that's just the example used):
-
wrong extensions
- jpg saved as gif (would be renamed back to jpg)
- gif saved as jpg (would be renamed back to gif)
-
missing extensions
- a jpg file named "foo" will be renamed "foo.jpg"
-
extra extensions
- a gif named "hello.png.jpg.kitty.gif" would be named "hello.kitty.gif"
-
repeating extensions
- changes ".jpg.jpg.jpg" to ".jpg"
- changes "foo.jpg.bar.jpg" to "foo.bar.jpg"
- leaves repeating non-image extensions untouched
-
mis-positioned extensions
- "foo.jpg.bar" will become "foo.bar.jpg"
-
annoying minor variances
- jpgs saved as .jpeg
- jpgs saved as .jfif
- jpgs saved as .jpg_large
- jpgs saved as .jpg_name=orig
It does this for ALL files that are detected as images via header.
The ONLY ones it skips are .bak files and files ending in ~
This may not be the behavior you like. It wasn't for me, until I added the exception for .bak and ~ files ;)
Install the appropriate packages:
pip install -r requirements.txt
Get clairecjs_utils:
pip install clairecjs_utils
Actually, that probably won't work, and you'll just have to manually grab the actual clairecjs_utils files from here. This one uses claire_console.py to cycle the foreground color while it is running. Purely for fun. Can easily be removed from the code by searching for "Claire" and commenting out those lines.
Two unit test files provided to prove it actually works
Feel free to make your own version with neato changes, if you are so inspired.
I use TCC -- Take Command Command Line. Technically, my .BAT files are .BTM files. If you want to get the ones I have working, I'd love to help.