Find and rename recurisively


kizer

Recommended Posts

With my Media I use Plex and an old Asrock ION 330 with XBMC installed. Long story short it works for my needs. 

 

When I rip a new disc and place it on my server Plex does its META Data thing, but I needed the extra files movie.nfo, movie.tbn, Fanart.jpg and obviously the Video file using a plugin called Lambda.

 

The problem I'm having is I need to convert movie.jpg to movie.tbn, which isn't that hard. Lol

I was tinkering with using find, but I'm kinda loosing my mind trying to determine some syntax and I was hoping somebody could lend me a hand. I used the following:

 

find /mnt/cache/Movies/ -iname 'movie.jpg' -exec mv '{}' movie.tbn \;

 

However if I have 5 Movies in 5 folders I want the movie.jpg to be renamed in its folder like so'

 

/Transformers

..movie.tbn

 

/Rambo

..movie.tbn

 

/Dumbo

..movie.tbn

 

The problem I'm seeing is its creating a movie.tbn in the root not in each folder.  I'm guessing its a syntax issues. 

/Transformers

/Rambo

/Dumbo

movie.tbn

 

Link to comment

Kinda solved this on my own just incase anybody else is ever looking for this solution. Not 100% how all the code worked, but tested and works. Lol

 

find /mnt/cache/test -type f -name 'movie.jpg' | while read f; do mv -v "$f" "${f%.*}.tbn"; done

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.