only move if the path contains a space

This commit is contained in:
Josh Junon 2024-04-16 17:24:58 +02:00
parent 99c6710f1a
commit 693c72b89a
No known key found for this signature in database

View File

@ -7,10 +7,13 @@ set -euo pipefail
ROOT_DIR="${1:-}"
if [ -z "$ROOT_DIR" ]; then
echo "Usage: $0 <directory>"
exit 1
echo "Usage: $0 <directory>"
exit 1
fi
find "$ROOT_DIR" -type f -name '*' -print0 | while IFS= read -r -d '' file; do
mv -v "$file" "$(echo "$file" | tr ' ' '+')"
new_file="$(echo "$file" | tr ' ' '+')"
if [[ "$file" != "$new_file" ]]; then
mv -v "$file" "$new_file"
fi
done