Skip to content

Instantly share code, notes, and snippets.

@sgarciav
Last active October 9, 2025 20:26
Show Gist options
  • Select an option

  • Save sgarciav/fc665859e23687708cfb7916b0ce7191 to your computer and use it in GitHub Desktop.

Select an option

Save sgarciav/fc665859e23687708cfb7916b0ce7191 to your computer and use it in GitHub Desktop.
Recursively rename parts of a file from the terminal

Suppose you have a directory with files named rb_001.png and so on with increasing numbers. And you want to rename the rgb part of the name to image. You'll cd into that directory and execute:

find . -type f -exec rename 's/rgb/image/' '{}' \;

You'll need to install:

sudo apt-get update && sudo apt-get install rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment