diff options
Diffstat (limited to 'sanitize')
| -rwxr-xr-x | sanitize | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sanitize b/sanitize new file mode 100755 index 0000000..c99a31e --- /dev/null +++ b/sanitize @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# This script sanitizes a given file or directory. Can take multiple files/dirs +# as argument. +# It replaces all whitespace and special characters with a dash, removes ?, ! +# and various types of brackets entirely and translates all characters to +# lower case. Camel case is also translated to dashes. +# Basically, the goal is to have filenames with ONLY lower case and dashes. + +# Behold the most disgusting regex ever + +perl-rename 's|([a-z])([A-Z])|$1-$2|g;s/\,//g;s/\x27//g;s/\.(?![^.]+$)//g;s/\&/and/g;s/@/-/g;s/ /-/g;s/_/-/g;s/--+/-/g;s/\[//g;s/\]//g;s/\(//g;s/\)//g;s/\{//g;s/\}//g;s/【//g;s/】//g;s/://g;s/\!+//g;s/?//g;s/|//g;s/\"//g;s/“//g;s/”//g;y/A-Z/a-z/' "$@"; |
