#!/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."