Files
popcorntime/scripts/normalize-spaces.sh
Pochoclin cb56278a9f feat: initial commit
fix: fmt

Signed-off-by: pochoclin <hey@popcorntime.app>
2025-09-15 17:08:48 -04:00

19 lines
411 B
Bash
Executable File

#!/usr/bin/env bash
#
# Finds all files in a directory and renames all spaces to '_'.
set -euo pipefail
ROOT_DIR="${1:-}"
if [ -z "$ROOT_DIR" ]; then
echo "Usage: $0 <directory>"
exit 1
fi
find "$ROOT_DIR" -type f -name '*' -print0 | while IFS= read -r -d '' file; do
new_file="$(echo "$file" | tr ' ' '_')"
if [[ "$file" != "$new_file" ]]; then
mv -v "$file" "$new_file"
fi
done