Created
February 10, 2013 08:54
-
-
Save ernestom/4748914 to your computer and use it in GitHub Desktop.
Fix imgur mistakes :(
These one liners rename files with jpg extension to gif extension if their mime type is image/gif, after replacing spaces with underscores and jpeg with jpg.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # depends on `brew install rename` | |
| cd ~/Pictures/pics | |
| find . | rename 's/\ /_/g' | |
| find . -iname '*.jpeg' | rename 's/jpeg$/jpg/g' | |
| find . -iname '*.jpg' -exec file -F '' --mime {} \; \ | |
| | grep -i 'image/gif' | awk '{print $1}' \ | |
| | while read file; do bn=`basename -s .jpg $file`; mv $bn.jpg $bn.gif; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment