File size: 562 Bytes
913e47d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#!/bin/bash
# Find all files and directories recursively, sort them so longer paths are processed first
# to avoid issues with parent directories being renamed before their contents.
find . -depth -print0 | while IFS= read -r -d $'\0' file; do
# Check if the filename contains a colon
if [[ "$file" == *:* ]]; then
# Create the new filename by replacing all colons with underscores
new_file="${file//:/_}"
# Rename the file/directory
mv -- "$file" "$new_file"
echo "Renamed: '$file' -> '$new_file'"
fi
done
echo "Renaming complete."
|