one day of code

Find and rename multiple files recursively

February 07, 2021

I had a situation recently where I needed to rename a bunch of same-named files that were located in different directories/depths. If you found yourself in this situation, I got you covered 😎 with this bash one-liner.

for f in ./**/*.ext; do mv -f "$f" "${f//old-name.ext/new-name.ext}"; done;

Disclamer: MacOS, zsh, Alacritty

Written by Milan Miljkovic — a tech enthusiast and design system practitioner.