From 1d997e7d68fe0ab078581c5e9bcd722bc0a5985d Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sat, 11 Mar 2006 08:05:42 +0000 Subject: [PATCH] * add support for dealing with anime filenames to sanitize_filename --- sanitize_filename | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sanitize_filename b/sanitize_filename index 41f8b39..3e6d705 100755 --- a/sanitize_filename +++ b/sanitize_filename @@ -1,4 +1,29 @@ #! /bin/sh # 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! -rename 's/\s+/\_/g; $_ = lc($_); s/\_+/\_/g; s/\_\././' "$@" +set - $(getopt -u --longoptions 'anime' -- '' "$@") +set -e + +ANIME_CUT=0 + + +while [ $1 != '--' ]; do + case $1 in + --anime) + ANIME_CUT=1 + ;; + --restart) + RESTART=1 + ;; + --force) + FORCE=1 + ;; + esac; + shift +done; +shift; +if [ "$ANIME_CUT" == 0 ]; then + rename 's/\s+/\_/g; $_ = lc($_); s/\_+/\_/g; s/\_\././' "$@" +else + rename 's/\[[^\]]+\]//g; s/^_+//; s/\s+/\_/g; $_ = lc($_); s/[_-]+/\_/g; s/\_\././' "$@" +fi; \ No newline at end of file -- 2.39.2