The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-26-2009
..Chris.. ..Chris.. is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
Exclamation Batch rename recursively

I would like to replace multiple underscores with hyphens but I have 26,000 files to rename. They are all in one file structure and multiple sub-directories.

It would be much simpler if I had a script to do it. Here are some samples of the file names:

Example 1
books/horrors/small/books_horrors_small_0000000386.jpg

Rename to

books/horrors/small/books-horrors-small-0000000386.jpg

Example 2
books/comedy/small/books_comedy_small_0000001687.jpg

Rename to

books/comedy/small/books-comedy-small-0000001687.jpg

There are 26,000 files that look similer to that and are all in different directories.

The only thing I need to do is replace all the underscores _ with hyphens -