Last active
November 10, 2015 22:42
-
-
Save plesiv/5e39c46e2620774f708a to your computer and use it in GitHub Desktop.
Shell functions for filename normalization
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
# normalize string given as an argument | |
n() { sed -e 's/^[ -]\+//' -e 's/[ -]\+$//' -e 's/[ ()-]\+/-/g' -e "s/'//g" | tr '[:upper:]' '[:lower:]' $1; } | |
# normalize name of the single file (renames file) | |
m() { mv "$1" "$(echo $1 | n)"; } | |
# normalize names of all files in the current directory | |
f() { for i in *; do m "$i"; done; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment