X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=sanitize_filename;fp=sanitize_filename;h=11574bc91ac8bc65f051696ee94d6c86cae589c9;hb=351d1bbaddd11b8249891c227b49c6249784f84e;hp=13623ba1aba0154eecadf8d21716dbcd1540338d;hpb=20ef0fa6ddbdc944f067289207e78dcc10b7389d;p=bin.git diff --git a/sanitize_filename b/sanitize_filename index 13623ba..11574bc 100755 --- a/sanitize_filename +++ b/sanitize_filename @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash # replace spaces with underscores, lowercase everything, ditch multiple underscores, and ditch _.foo. # should probably try to avoid overwriting existing files, but c'est la vie! @@ -9,7 +9,7 @@ set -e ANIME_CUT=0 -while [ $1 != '--' ]; do +while [ $1 != "--" ]; do case $1 in --anime) ANIME_CUT=1 @@ -25,7 +25,7 @@ while [ $1 != '--' ]; do done; shift; if [ "$ANIME_CUT" == 0 ]; then - rename 's/\s+/\_/g; s/[^\w\d.]/\_/g; s/_$//g; $_ = lc($_); s/\_+/\_/g; s/\_\././; s/^_+//g;' "$@" + rename 's/\s+/\_/g; s/[^\w\d.]/\_/g; s/_$//g; $_ = lc($_); s/\_+/\_/g; s/\_\././; s/^_+//g;' -- "$@" else - rename 's/\[[^\]]+\]//g; s/\([^\)]+\)//g; s/\s+/\_/g; $_ = lc($_); s/[_-]+/\_/g; s/\_\././; s/^_+//;' "$@" + rename 's/\[[^\]]+\]//g; s/\([^\)]+\)//g; s/\s+/\_/g; $_ = lc($_); s/[_-]+/\_/g; s/\_\././; s/^_+//;' -- "$@" fi; \ No newline at end of file