On Dec 1, 2011 8:54 AM, "Dale" <rdalek1...@gmail.com> wrote: > > Greets, > > I ran into a problem. I been downloading a lot of TV shows. I forgot to put a sort of important part in the names. This is what I have with the full path: > > /data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4 > > This is what I need it to be: > > /data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1, Episode 1 - Pilot.mp4 > > Basically, I need to add the name of the show to the name of the file. They will all be added to the front of the names. They also almost all contain spaces, which means some fancy footwork with the \. > > Is there a way to do this? I have room to copy them to another directory if needed. I would sort of actually prefer it that way since if it messes up, I got the originals at least. > > Sorry I'm not real good at gawk, sed and all those things. I suspect those will be used tho. I am familiar with | and grep tho. ;-) > > Thoughts? >
'find' and 'mv' should do the job. With some help from 'dirname' and 'basename'. E. g. find $PATHTOMOVIES -name "*. mp4" -exec mv "{}" "\$(dirname {})/$(basename $(dirname {})) - $(basename {})" Not tested, though. So you'd better use 'echo' instead of 'mv' for a dry run. Rgds,