Skip to content

Instantly share code, notes, and snippets.

@nucleardreamer
Created June 16, 2023 17:10
Show Gist options
  • Save nucleardreamer/d70e7ecfea03f5f36dbfe044b73cd045 to your computer and use it in GitHub Desktop.
Save nucleardreamer/d70e7ecfea03f5f36dbfe044b73cd045 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
find . -depth -not -path '*/\.*' | while read file ; do
directory=$(dirname "$file")
filename=$(basename "$file")
newfilename=$(echo "$filename" | sed 's/[^a-zA-Z0-9_. -]//g' | tr '[:upper:]' '[:lower:]')
if [ "$filename" != "$newfilename" ]; then
mv "$directory/$filename" "$directory/$newfilename"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment