2023-04-28 21:32:21 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# for i in *placehoder*; do mv "$i" "${i//placeholder/replacement}" done
|
|
|
|
|
|
|
|
replacements=
|
|
|
|
declare -A replacements
|
|
|
|
unset replacements[0]
|
|
|
|
replacements[' ']='_';
|
|
|
|
replacements[':']='_';
|
2023-05-27 18:11:37 +02:00
|
|
|
replacements["'"]='_';
|
|
|
|
replacements['(']='_';
|
|
|
|
replacements[')']='_';
|
2024-01-18 15:50:08 +01:00
|
|
|
replacements['[']='_';
|
|
|
|
replacements[']']='_';
|
2023-04-28 21:32:21 +02:00
|
|
|
while [[ $# > 0 ]]; do
|
|
|
|
replacements["$1"]="$2";
|
|
|
|
shift 2;
|
|
|
|
done
|
|
|
|
|
|
|
|
for toReplace in "${!replacements[@]}"; do
|
|
|
|
echo "$toReplace"
|
|
|
|
replacement=${replacements[$toReplace]}
|
|
|
|
echo "$replacement"
|
|
|
|
for i in *; do
|
|
|
|
echo "$i"
|
|
|
|
if [[ ! -e "$i" || "$i" == "${i//$toReplace/$replacement}" ]]; then
|
|
|
|
continue; # weird behaviour with single space makes this necessary
|
|
|
|
fi
|
|
|
|
echo "mv $i -> ${i//$toReplace/$replacement}";
|
|
|
|
mv "$i" "${i//$toReplace/$replacement}";
|
|
|
|
done
|
|
|
|
done
|