[kwlug-disc] bulk renaming with regex

Doug Moen doug at moens.org
Wed Sep 28 21:34:52 EDT 2022


Sounds feasible, but what pattern do you want to rename the files to?

For bulk renaming, instead of using a bulk renaming tool with a limited pattern language, I put all of the filenames into a text file, one filename per line, then I use a sequence of vim substitute commands to convert each filename into a shell command that uses 'mv' to rename the file. Then I execute the file as a shell script. Since I have the full power of the text editor available, there's no kind of rename that is out of reach. I can read the text file and verify that the renames are correct before I execute them.

In vim, I would type something like
  :s,^\(.*\) - s\([0-9]*\)e\([0-9]*\)$,mv '\0' '\1_season\2_episode\3',

On Wed, Sep 28, 2022, at 7:54 PM, Charles M 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
> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org




More information about the kwlug-disc mailing list