From: Pandu Poluan <pandu@poluan.info>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Changing names of LOTS of files, adding to them actually.
Date: Thu, 1 Dec 2011 09:29:28 +0700 [thread overview]
Message-ID: <CAA2qdGVjW3jZQFBQqeNJFHHzZbfnAfOo3QZxk=3=D0AB3Mtoig@mail.gmail.com> (raw)
In-Reply-To: <CAA2qdGX4qMHPhA6wfcKO61HFH6YSMLxrzb2C6h8F5BG3Zkc8rg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]
On Dec 1, 2011 9:22 AM, "Pandu Poluan" <pandu@poluan.info> wrote:
>
>
> On Dec 1, 2011 8:54 AM, "Dale" <rdalek1967@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.
>
Whoopsies. I certainly must've made some mistakes with the escaping
there...
Oh well, just write a short script containing this:
mv "$1" "$(dirname $1)/$(basename $(dirname $1)) - $(basename $1)"
and feed that script (after chmod +x, of course) to the -exec part of
find, e.g.
find ... -exec scriptname.sh {} \;
Rgds,
[-- Attachment #2: Type: text/html, Size: 2306 bytes --]
next prev parent reply other threads:[~2011-12-01 2:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-01 1:49 [gentoo-user] Changing names of LOTS of files, adding to them actually Dale
2011-12-01 2:18 ` Frank Steinmetzger
2011-12-01 2:46 ` Dale
2011-12-01 2:19 ` Francisco Ares
2011-12-01 2:23 ` Francisco Ares
2011-12-01 2:22 ` Pandu Poluan
2011-12-01 2:29 ` Pandu Poluan [this message]
2011-12-01 2:22 ` bill.longman
2011-12-01 3:23 ` Frank Steinmetzger
2011-12-01 4:18 ` Dale
2011-12-01 8:53 ` Neil Bothwick
2011-12-01 9:34 ` Stroller
2011-12-01 10:42 ` Dale
2011-12-01 15:29 ` Frank Steinmetzger
2011-12-02 17:33 ` James Broadhead
2011-12-02 10:50 ` Stroller
2011-12-02 15:43 ` Frank Steinmetzger
2011-12-01 10:55 ` Helmut Jarausch
2011-12-01 13:22 ` James Broadhead
2011-12-01 13:51 ` Paul Hartman
2011-12-02 10:21 ` Stroller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA2qdGVjW3jZQFBQqeNJFHHzZbfnAfOo3QZxk=3=D0AB3Mtoig@mail.gmail.com' \
--to=pandu@poluan.info \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox