From 351d1bbaddd11b8249891c227b49c6249784f84e Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 2 Apr 2010 13:54:30 +0000 Subject: [PATCH] fixup sanitize filename to handle leading - properly --- sanitize_filename | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 -- 2.39.2