[SFS] Struggling with regex / file renaming
Shannon Dillman
shannon.dillman@gmail.com
Thu, 14 Jul 2016 13:37:19 -0400
--001a1143e8e87f711205379bf692
Content-Type: text/plain; charset=UTF-8
Might want to give http://www.filebot.net/ a look. Pre-built packages are
available, and everything's on SourceForge
<https://sourceforge.net/projects/filebot/> and Github
<https://github.com/filebot/filebot>.
On Thu, Jul 14, 2016 at 1:03 PM, Matt James <matuse@gmail.com> wrote:
> thanks Aaron, quotes worked like a charm - not sure why I didn't try
> that....
>
> Davide - yea, I know - I don't like the spaces either, but my bigger
> issue was plex not linking the season / episode numbers together - had
> to separate them anyway.
>
> Mike - never heard of sonaar - I'll look into it.
>
> Thanks everyone for helping the helpless. :-)
>
> Matt
>
> On Thu, Jul 14, 2016 at 8:45 AM, Aaron Brown <aayore@gmail.com> wrote:
> > Seemed to work fine for me by quoting the entirety of each variable:
> >
> > for f in *.mpg; do mv "$f" "$(echo $f | sed -e
> > 's/\([0-9][0-9]\)\([0-9][0-9]\)/s\1e\2/')"; done
> >
> > Matt James
> > July 13, 2016 at 11:52 PM
> > Gents,
> > So - I'm trying to clean up some file names so that plex will index
> > my Simpsons episodes correctly.
> >
> > Currently, I have stuff named like this:
> >
> > 1205 Homer vs. Dignity.mpg
> > 1206 The Computer Wore Menace Shoes.mpg
> > 1207 The Great Money Caper.mpg
> > 1208 Skinner's Sense of Snow.mpg
> >
> > That is - first two numbers are the season, second two are the episode.
> >
> > I'd like to rename them like this:
> >
> > s12e05 Homer vs. Dignity.mpg
> > s12e06 The Computer Wore Menace Shoes.mpg
> > s12e07 The Great Money Caper.mpg
> > s12e08 Skinner's Sense of Snow.mpg
> >
> > so, after a little man pages and google, I tried the following:
> >
> > matt@owncloud:/backup/SIMPSONS/12$ for f in *.mpg; do echo mv $f
> > $(echo $f | sed -e 's/\([0-9][0-9]\)\([0-9][0-9]\)/s\1e\2/'); done
> > mv 1205 Homer vs. Dignity.mpg s12e05 Homer vs. Dignity.mpg
> > mv 1206 The Computer Wore Menace Shoes.mpg s12e06 The Computer Wore
> > Menace Shoes.mpg
> > mv 1207 The Great Money Caper.mpg s12e07 The Great Money Caper.mpg
> > mv 1208 Skinner's Sense of Snow.mpg s12e08 Skinner's Sense of Snow.mpg
> >
> > Basically, I'm searching for a group of two numbers and then another
> > two numbers and then I'm replacing with an "s", then group 1, then
> > "e", then group 2, and then the rest of the file name.
> > this seems to do what I want, except when I take out the "echo" in the
> > for loop - it doesn't actually work because I'm not escaping the
> > spaces correctly (I think that's why it's failing anyway)
> >
> > so - I tried this:
> >
> > matt@owncloud:/backup/SIMPSONS/12$ for f in *.mpg; do echo mv $f
> > ${f/([0-9][0-9])([0-9][0-9])/s\1e\2/}; done
> > mv 1205 Homer vs. Dignity.mpg 1205 Homer vs. Dignity.mpg
> > mv 1206 The Computer Wore Menace Shoes.mpg 1206 The Computer Wore
> > Menace Shoes.mpg
> > mv 1207 The Great Money Caper.mpg 1207 The Great Money Caper.mpg
> > mv 1208 Skinner's Sense of Snow.mpg 1208 Skinner's Sense of Snow.mpg
> >
> > but, as you can see - it's not matching the search anymore and so it
> > just returns the same filename instead of the modified one.
> >
> > What am I missing? Is there a better way? It's almost midnight - I'm
> > putting this down for now - maybe one of you can help....
> >
> > Matt
> > _______________________________________________
> > SFS mailing list
> > SFS@thegeek.nu
> > http://mailman.thegeek.nu/mailman/listinfo/sfs
> >
> >
> _______________________________________________
> SFS mailing list
> SFS@thegeek.nu
> http://mailman.thegeek.nu/mailman/listinfo/sfs
>
--001a1143e8e87f711205379bf692
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Might want to give=C2=A0<a href=3D"http://www.filebot.net/=
">http://www.filebot.net/</a> a look. Pre-built packages are available, and=
everything's on <a href=3D"https://sourceforge.net/projects/filebot/">=
SourceForge</a> and <a href=3D"https://github.com/filebot/filebot">Github</=
a>.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Thu, =
Jul 14, 2016 at 1:03 PM, Matt James <span dir=3D"ltr"><<a href=3D"mailto=
:matuse@gmail.com" target=3D"_blank">matuse@gmail.com</a>></span> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">thanks Aaron, quotes worked like a charm=
- not sure why I didn't try that....<br>
<br>
Davide - yea, I know - I don't like the spaces either, but my bigger<br=
>
issue was plex not linking the season / episode numbers together - had<br>
to separate them anyway.<br>
<br>
Mike - never heard of sonaar - I'll look into it.<br>
<br>
Thanks everyone for helping the helpless.=C2=A0 :-)<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
Matt<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
On Thu, Jul 14, 2016 at 8:45 AM, Aaron Brown <<a href=3D"mailto:aayore@g=
mail.com">aayore@gmail.com</a>> wrote:<br>
> Seemed to work fine for me by quoting the entirety of each variable:<b=
r>
><br>
> for f in *.mpg; do mv "$f" "$(echo $f | sed -e<br>
> 's/\([0-9][0-9]\)\([0-9][0-9]\)/s\1e\2/')"; done<br>
><br>
> Matt James<br>
> July 13, 2016 at 11:52 PM<br>
> Gents,<br>
> So - I'm trying to clean up some file names so that plex will inde=
x<br>
> my Simpsons episodes correctly.<br>
><br>
> Currently, I have stuff named like this:<br>
><br>
> 1205 Homer vs. Dignity.mpg<br>
> 1206 The Computer Wore Menace Shoes.mpg<br>
> 1207 The Great Money Caper.mpg<br>
> 1208 Skinner's Sense of Snow.mpg<br>
><br>
> That is - first two numbers are the season, second two are the episode=
.<br>
><br>
> I'd like to rename them like this:<br>
><br>
> s12e05 Homer vs. Dignity.mpg<br>
> s12e06 The Computer Wore Menace Shoes.mpg<br>
> s12e07 The Great Money Caper.mpg<br>
> s12e08 Skinner's Sense of Snow.mpg<br>
><br>
> so, after a little man pages and google, I tried the following:<br>
><br>
> matt@owncloud:/backup/SIMPSONS/12$ for f in *.mpg; do echo mv $f<br>
> $(echo $f | sed -e 's/\([0-9][0-9]\)\([0-9][0-9]\)/s\1e\2/'); =
done<br>
> mv 1205 Homer vs. Dignity.mpg s12e05 Homer vs. Dignity.mpg<br>
> mv 1206 The Computer Wore Menace Shoes.mpg s12e06 The Computer Wore<br=
>
> Menace Shoes.mpg<br>
> mv 1207 The Great Money Caper.mpg s12e07 The Great Money Caper.mpg<br>
> mv 1208 Skinner's Sense of Snow.mpg s12e08 Skinner's Sense of =
Snow.mpg<br>
><br>
> Basically, I'm searching for a group of two numbers and then anoth=
er<br>
> two numbers and then I'm replacing with an "s", then gro=
up 1, then<br>
> "e", then group 2, and then the rest of the file name.<br>
> this seems to do what I want, except when I take out the "echo&qu=
ot; in the<br>
> for loop - it doesn't actually work because I'm not escaping t=
he<br>
> spaces correctly (I think that's why it's failing anyway)<br>
><br>
> so - I tried this:<br>
><br>
> matt@owncloud:/backup/SIMPSONS/12$ for f in *.mpg; do echo mv $f<br>
> ${f/([0-9][0-9])([0-9][0-9])/s\1e\2/}; done<br>
> mv 1205 Homer vs. Dignity.mpg 1205 Homer vs. Dignity.mpg<br>
> mv 1206 The Computer Wore Menace Shoes.mpg 1206 The Computer Wore<br>
> Menace Shoes.mpg<br>
> mv 1207 The Great Money Caper.mpg 1207 The Great Money Caper.mpg<br>
> mv 1208 Skinner's Sense of Snow.mpg 1208 Skinner's Sense of Sn=
ow.mpg<br>
><br>
> but, as you can see - it's not matching the search anymore and so =
it<br>
> just returns the same filename instead of the modified one.<br>
><br>
> What am I missing? Is there a better way? It's almost midnight - I=
'm<br>
> putting this down for now - maybe one of you can help....<br>
><br>
> Matt<br>
> _______________________________________________<br>
> SFS mailing list<br>
> <a href=3D"mailto:SFS@thegeek.nu">SFS@thegeek.nu</a><br>
> <a href=3D"http://mailman.thegeek.nu/mailman/listinfo/sfs" rel=3D"nore=
ferrer" target=3D"_blank">http://mailman.thegeek.nu/mailman/listinfo/sfs</a=
><br>
><br>
><br>
_______________________________________________<br>
SFS mailing list<br>
<a href=3D"mailto:SFS@thegeek.nu">SFS@thegeek.nu</a><br>
<a href=3D"http://mailman.thegeek.nu/mailman/listinfo/sfs" rel=3D"noreferre=
r" target=3D"_blank">http://mailman.thegeek.nu/mailman/listinfo/sfs</a><br>
</div></div></blockquote></div><br></div>
--001a1143e8e87f711205379bf692--