first commit

This commit is contained in:
2025-10-09 10:55:52 +02:00
commit 6be8201511
20 changed files with 2132 additions and 0 deletions

40
rename_space.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
# Standardvärden
DIR="."
DRY_RUN=false
# Läs argument
for arg in "$@"; do
case "$arg" in
--dry-run)
DRY_RUN=true
;;
*)
DIR="$arg"
;;
esac
done
# Gå igenom alla filer i katalogen rekursivt
find "$DIR" -depth -type f | while read -r file; do
dir=$(dirname "$file")
base=$(basename "$file")
# Byt ut mellanslag mot underscore
newbase=$(echo "$base" | tr ' ' '_')
# Byt ut flera underscores mot en enda
newbase=$(echo "$newbase" | sed 's/_\+/_/g')
# Om namnet har ändrats
if [ "$base" != "$newbase" ]; then
newpath="$dir/$newbase"
if [ "$DRY_RUN" = true ]; then
echo "[Dry-run] $file -> $newpath"
else
echo "Renaming: $file -> $newpath"
mv -i "$file" "$newpath"
fi
fi
done