DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Rename *nix Filenames

10.06.2006
| 7561 views |
  • submit to reddit
        
I am a bit slow sometimes and it took me a while to find this unix command that most are probably already aware of. rename is a very useful tool. The example I have here will susbtitute "foo" for "bar" of any file with foo in the name. The really nice thing about this is that it can use and regular expression syntax (ie. "^", "$", etc..).

rename -n 's/foo/bar/' *foo*