Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

20
  • 7
    No need for two steps: Use Depth-first search: find dir -depth Commented Apr 25, 2010 at 20:01
  • 4
    Oh, I've just read the rename manpage (I didn't know the tool) and I think you can optimize your code by changing s/ /_/g to y/ /_/ ;-) Commented Apr 26, 2010 at 14:45
  • 25
    If you're running this on OS X, you'll need to brew install rename
    – loeschg
    Commented Aug 8, 2014 at 17:54
  • 12
    This doesn't work on Centos 7, as the rename command is completely different (it's a binary, not a perl script), and it doesn't accept data from stdin.
    – CpnCrunch
    Commented Nov 4, 2015 at 3:03
  • 3
    @CpnCrunch Same in RHEL 6.2 and Cygwin (rename --version says rename from util-linux 2.x.x, but a good tool for mass renaming anyway
    – golimar
    Commented Dec 14, 2016 at 11:32