Batch rename with wildcard support in Unix


/ Published in: Bash
Save to your folder(s)

To rename a bunch of files from "*.foo" to "*.bar" (like windows' REN *.foo *.bar) in unix.

Looking at the solution, it is easy to adapt it to more powerful character substitutions on a 1 to 1 basis.

If you want to test what will be executed before doing so, just drop the last pipe.


Copy this code and paste it in your HTML
  1. ls -d *.foo | sed -e 's/.*/mv & &/' -e 's/foo$/bar/' | sh

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.