diff options
| author | yuzu-eva <cafebabe@disroot.org> | 2025-05-08 14:01:37 +0200 |
|---|---|---|
| committer | yuzu-eva <cafebabe@disroot.org> | 2025-05-08 14:01:37 +0200 |
| commit | ef7c1605a027b52bbff1b01ea693b60f53fa3a71 (patch) | |
| tree | 1089334258aefbd459d18cf6968e78f1194739b0 /sanitize | |
initial commit
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/' "$@"; |
