Skip to content

Instantly share code, notes, and snippets.

@mikequentel
Last active November 24, 2020 18:11
Show Gist options
  • Save mikequentel/6bc43299f4e2d73d53b5b3bc18009fc0 to your computer and use it in GitHub Desktop.
Save mikequentel/6bc43299f4e2d73d53b5b3bc18009fc0 to your computer and use it in GitHub Desktop.
rn.sh -- git mv to rename files by a source pattern and an expected output pattern
#!/bin/bash
# based on:
# https://stackoverflow.com/questions/9984722/git-rename-many-files-and-folders
OLD_PATTERN=$1
NEW_PATTERN=$2
for file in `git ls-files | grep "$OLD_PATTERN"`; do git mv -k $file `echo $file | sed -e "s|$OLD_PATTERN|$NEW_PATTERN|g"`; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment