#!/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/' "$@";