Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
batch rename files or folders recursively in bash
command to find recursively files {can be modified for folders too, change -type f}, and renamed them by specfying regex pattern
find . -type f -maxdepth [depth] -name "[filepattern]" | while read FNAME; do mv "$FNAME" "${FNAME//search/replace}"; done
find . -type f -maxdepth 1 -name "domain*.php" | while read FNAME; do mv "$FNAME" "${FNAME//domain/lead}"; done
before: after:
domains.php leads.php
domain.php lead.php
to do same for folders just change -type f --> -type d

This comment has been minimized.

Copy link

commented May 7, 2019

Thank you, very helpful :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.