Skip to content

Instantly share code, notes, and snippets.

@elegantcoder
Last active October 20, 2023 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elegantcoder/89c4de33ca85b8e5d95df5630fad1973 to your computer and use it in GitHub Desktop.
Save elegantcoder/89c4de33ca85b8e5d95df5630fad1973 to your computer and use it in GitHub Desktop.
Git-mv-singularize
# Get the original name and the singularized name
original_name="$1"
singularized_name=$(singularize "$original_name")
# Compare the original name and the singularized name
if [[ "$original_name" != "$singularized_name" ]]; then
# If they are different, execute git mv
git mv "$original_name" "$singularized_name"
fi
#!/usr/bin/env python
import sys
from pattern.en import singularize;
print(singularize(sys.argv[1]))
@elegantcoder
Copy link
Author

README

I hope you never find yourself in a situation where you need this tool.
However, if you do, I hope it proves to be helpful.

What is Git-mv-singularize

Git-mv-singularize is a tool designed to rename files and folders within a Git repository.
It renames files and folders to their singular form.

Pre-requisites

pip install pattern

Usage

find . -type d -maxdepth 1 -exec git-mv-singularize {} \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment