[kwlug-disc] bulk renaming with regex

Ronald Barnes ron at ronaldbarnes.ca
Wed Sep 28 20:29:09 EDT 2022


CrankyOldBugger wrote on 2022-09-28 17:16:

> I can't live without 'rename', which is available for Ubuntu, but I 
> don't think the Red Hat/Fedora program of the same name is the same thing.
> 
> The syntax is
> 
> rename -v 's/regex/newnames/' *
> 
> Or some such variation.  With regex it's actually very flexible.  So in 
> the case of your files, you'd do:
> 
> rename -v 's/\ -\ s01e/\ -\ s02e/' *
> 
> (assuming you wanted to change the s01 to s02)

This is possibly the only situation where the DOS command prompt beats 
the Linux / bash one.

 From memory, in DOS:

ren *s01* *s02*

...or...

ren *.htm *.html

Done.




Pathname Expansion in bash, nice as it is, will never allow this to happen.

It will expand "*.htm" to a list of all files that match the pattern, 
then pass that list to "mv" or "ren", making it impossible to determine 
the wildcard(s) used and their placement.

Quoting parameters helps, but then it's not like DOS. Disabling Pathname 
Expansion is possible, but since it's also useful, don't want to do that 
either.


/end rant






> 
> On Wed, Sep 28, 2022 at 7:54 PM Charles M <chaslinux at gmail.com 
> <mailto:chaslinux at gmail.com>> wrote:
> 
>     I have a bunch of videos I've ripped from my media and I'd like to
>     automate renaming of them. Xubuntu has a bulk renaming tool that will
>     let me rename the first part of the file. I'm wondering if there's a
>     simple regex that would work for renaming the second part (episodes).
> 
>     For example: I have a show that's the second season:
> 
>     showname - s01e01
>     showname - s01e02
>     showname - s01e03
> 
>     (Where s is season and e is episode)
> 
>     Does anyone use Xubuntu's bulk renaming tool to do something similar?
> 
>     Thanks,
> 
>     Charles
> 
>     _______________________________________________
>     kwlug-disc mailing list
>     kwlug-disc at kwlug.org <mailto:kwlug-disc at kwlug.org>
>     https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>     <https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org>
> 
> 
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org




More information about the kwlug-disc mailing list