Renaming multiple files in multiple directories.

Patrick Smith yellowdog-general@lists.terrasoftsolutions.com
Fri, 17 Sep 2004 18:17:18 -0400


Christopher Brown wrote:
> While ripping and encoding I accidentally named a good many of my files 
> incorrectly and added extra characters(ogg) before the dot like so: 
> (name-of-songogg.ogg)
> 
> What I want to do is rename all the files so they only have the name and 
> .ogg extension like this: (name-of-song.ogg).
> 
> The directory structure looks like this:
> (notice that the songs are at different levels but all inside the ogg 
> folder)
> /home/user/oggs/artist1/album1/name-of-song1ogg.ogg
> /home/user/oggs/artist2/name-of-song2ogg.ogg
> /home/user/oggs/artist3/greatesthits/album1/name-of-song3ogg.ogg

(Warning: I have not tested this.  Also, it assumes you don't have any 
files with ogg.ogg in the middle.)

find /home/user/oggs -name '*ogg.ogg' -print0 \
| xargs -0 rename ogg.ogg .ogg