Gentoo Archives: gentoo-user

From: Pandu Poluan <pandu@××××××.info>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Changing names of LOTS of files, adding to them actually.
Date: Thu, 01 Dec 2011 02:27:33
Message-Id: CAA2qdGX4qMHPhA6wfcKO61HFH6YSMLxrzb2C6h8F5BG3Zkc8rg@mail.gmail.com
In Reply to: [gentoo-user] Changing names of LOTS of files, adding to them actually. by Dale
1 On Dec 1, 2011 8:54 AM, "Dale" <rdalek1967@×××××.com> wrote:
2 >
3 > Greets,
4 >
5 > I ran into a problem. I been downloading a lot of TV shows. I forgot to
6 put a sort of important part in the names. This is what I have with the
7 full path:
8 >
9 > /data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4
10 >
11 > This is what I need it to be:
12 >
13 > /data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1,
14 Episode 1 - Pilot.mp4
15 >
16 > Basically, I need to add the name of the show to the name of the file.
17 They will all be added to the front of the names. They also almost all
18 contain spaces, which means some fancy footwork with the \.
19 >
20 > Is there a way to do this? I have room to copy them to another directory
21 if needed. I would sort of actually prefer it that way since if it messes
22 up, I got the originals at least.
23 >
24 > Sorry I'm not real good at gawk, sed and all those things. I suspect
25 those will be used tho. I am familiar with | and grep tho. ;-)
26 >
27 > Thoughts?
28 >
29
30 'find' and 'mv' should do the job. With some help from 'dirname' and
31 'basename'. E. g.
32
33 find $PATHTOMOVIES -name "*. mp4" -exec mv "{}" "\$(dirname {})/$(basename
34 $(dirname {})) - $(basename {})"
35
36 Not tested, though. So you'd better use 'echo' instead of 'mv' for a dry
37 run.
38
39 Rgds,

Replies

Subject Author
Re: [gentoo-user] Changing names of LOTS of files, adding to them actually. Pandu Poluan <pandu@××××××.info>