Last active
December 21, 2020 11:59
-
-
Save dbswebsite/f7ff88850dcf01fdafab5e66186cbdec to your computer and use it in GitHub Desktop.
Normalize image filenames, recursively.
This file contains 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 | |
# | |
# @file normalize.sh | |
# | |
# @requires the perl 'rename' utility | |
# | |
################################################################################ | |
# force to lowercase | |
find . -iregex ".+\.\(jpe?g\|png\)" | rename 'y/A-Z/a-z/' | |
# replace evil whitespace with dash | |
find . -iregex ".+\.\(jpe?g\|png\)"| rename 's/ /-/g' | |
# remove other non-useful, possbily illegal chars | |
find . -iregex ".+\.\(jpe?g\|png\)" -printf "%P\n" | rename 's/[^-_\.\+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]//g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add first ...
find -type d | rename 's/ /-/g'
find -type d | rename 'y/A-Z/a-z/'
to fix any subdirectory names that might be fubar as well.