Skip to content

Instantly share code, notes, and snippets.

@QuentinBrosse
Last active August 31, 2021 09:33
Show Gist options
  • Save QuentinBrosse/d091edad3ca5c8ea5f350996a13d576b to your computer and use it in GitHub Desktop.
Save QuentinBrosse/d091edad3ca5c8ea5f350996a13d576b to your computer and use it in GitHub Desktop.
This script renames all PascalCase python files in the current directory into camel_case version.
#!/usr/bin/env bash
# This script renames all PascalCase python files in the current directory into camel_case version.
# Note: gsed is the GNU sed; on macOS install with `brew install gnu-sed`
for path in $(find . -maxdepth 1 -regex '\./[A-Z].*\.py')
do
pascal_case=$(echo $path | cut -c 3-)
camel_case=$(echo $pascal_case | gsed -E 's/([A-Z])/_\L\1/g' | cut -c 2-)
git mv $pascal_case $camel_case
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment