Git: Rename or move all files at once

for i in $(find . -iname "*.erb"); do
    git mv "$i" "$(echo $i | rev | cut -d '.' -f 2- | rev).haml";
done

For each .erb file, git mv it to itself with the extension ".erb" replaced by ".haml".


A one liner using powershell

Dir *.erb -Recurse | foreach { git mv $_.FullName $_.FullName.replace("erb", "haml")}

This worked for me using Powershell:

Get-ChildItem -File | foreach { git mv ($_.BaseName+".js") ($_.BaseName+".ts") }

For safety I chose not to add -Recurse.

Replace file extensions with whatever you need.

Tags:

Git