Skip to content

Instantly share code, notes, and snippets.

@isayev
Created April 25, 2014 16:17
Show Gist options
  • Save isayev/11294997 to your computer and use it in GitHub Desktop.
Save isayev/11294997 to your computer and use it in GitHub Desktop.
Shell script to rename files with brackets & white space to underscores
find . -depth -name '*(*' | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr '(' _)" ; done
find . -depth -name '*)*' | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ')' _)" ; done
find . -depth -name '* *' | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment