Create a gist now

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
example:
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment