Skip to content

Instantly share code, notes, and snippets.

@phun-ky
Created January 31, 2014 05:22
Show Gist options
  • Save phun-ky/8726964 to your computer and use it in GitHub Desktop.
Save phun-ky/8726964 to your computer and use it in GitHub Desktop.
# Rename multiple files
# http://www.24hourapps.com/2009/03/linux-tips-10-rename-multiple-files.html
# https://gist.github.com/alobato/397988
#
# Found the orignal gist very helpfull, and tweaked it to fit git mv
# First I suggest you test the outcome before you do the renaming, with a dry run (-n)
for f in $(git ls-files | grep %filestomatch%); do git mv -n "${f}" "${f/%filestomatch%/%newfilename_orlocation%}"; done;
# If you are happy with the result, execute ( remove -n )
for f in $(git ls-files | grep %filestomatch%); do git mv "${f}" "${f/%filestomatch%/%newfilename_orlocation%}"; done;
# It is quite a long command, but it basically executes a loop and tells it to take each f file
# name in the grepped result from git ls-files and give it a name where a match for %filestomatch% is replaced with %newfilename_orlocation%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment