Bulk Rename Folders for Jellyfin Library (Sed/Awk)?

Hello everyone, happy Monday! If this topic isn’t in the right place, or just doesn’t belong on the forum, feel free to delete.

I have a large folder of anime, and I’m trying to import it into Jellyfin. I think I’d have a lot more luck with Jelly getting the correct metadata if I cleaned up the folder names and removed things like the [SubGroup] or (1080p)[HEVC] type stuff like that from the folder names.

Is anyone here savvy enough with sed, awk, or any other bash type utility where I could possibly run it recursively on this folder to prune the extra information from the folders? It would definitely save me a lot of time :slight_smile: Also, I do have a full backup of this folder, so while I’d like to avoid clobbering all the file names with a bad command, it’s not the end of the world if something happens.

Some examples of the folders I need to rename, there’s a lot of variation with how these are labeled so I’m not sure what the best way to go about this would be - I was thinking of trying to just remove anything that was contained in [] brackets or () parenthesis, including the brackets or parenthesis themselves.

'Kobayashi-san Chi no Maid Dragon (Season 1+Mini+Extra) [Dual Audio][BD][1080p][HEVC 10bit x265][AAC][Eng Sub]'
'Kokoro Connect_-_(Dual Audio_10bit_BD1080p_x265)'
'[neoHEVC] Desert Punk - Sunabouzu [DVD 480p x265 HEVC AAC]'
'[neoHEVC] Wandering Witch - The Journey of Elaina [Season 1] [BD 1080p x265 HEVC AAC] [Dual Audio]'
'[Judas] Tensei Shitara Slime Datta Ken (Season 1 + OADs) [BD 1080p][HEVC x265 10bit][Dual-Audio][Multi-Subs]'
'[Judas] Tensei Shitara Slime Datta Ken (Season 2) [1080p][HEVC x265 10bit][Multi-Subs]'
'[Judas] Working!! (Seasons 1-3) [BD 1080p][HEVC x265 10bit][Eng-Subs]'

Overall having a LOT of fun playing with Jellyfin. It did an excellent job importing my music library, and Tauon Music Box is absolutely awesome - Highly recommend checking it out if anyone else is interested in this.

maybe try a tool for media renaming like filebot or something in that spirit ?

1 Like

A couple of things:

  • zmv, which is part of zsh, is really good at that type of variable renaming
  • I don’t use jellyfin but are you sure it reads the folder names for that matching? Most of those tools read the filenames and/or the file metadata.
2 Likes

What @dalto suggested, zmv is really nice.

An alternative (if you do not use Zsh, for example) is qmv from rename-utils package. I usually set up an alias for it:

alias rename='qmv --format=do'

So, when I run rename in a directory, a text editor opens with a temporary file containing the directory listing. Whatever I change there, after saving, gets applied to the actual filenames.

1 Like

For bulk renaming I can only recommend Thunar's build-in bulk renaming. I have not found anything even close to it. Terminal tools are probably as good as your text editor - so for you it may be a better option.

1 Like

Thank ya’ll very much, I’ll look into these suggestions and give one a try :+1:

And Dalto yes - Jelly uses the file metadata first, but if it can’t determine what the episode information is based off of that, it then reads the file & folder name to see if it can use that as a “fallback” method to find the metadata online.

I tested on one of the series that didn’t have the metadata automatically pulled from AniDB - I removed the extra [SubGroup] and tailing info, rescanned the library, and wim-wam-wazzle, Jelly was able to correctly grab the series info after that :slight_smile:

1 Like

https://www.filebot.net/

FileBot is the ultimate tool for renaming and organizing your movies, TV shows and Anime. Match and rename media files against online databases, download artwork and cover images, fetch subtitles, write metadata, and more, all at once in matter of seconds. It’s smart and just works.

1 Like

I’m experimenting with this now, it looks extremely promising. I may end up actually buying a license for it because I anticipate my collection will grow, and this looks very useful.

Thank you for the suggestion!

1 Like

its been a really long time since I looked at it but back in the days there were not much to gain by buying a license. The free version was really powerful and everything needed.

There is also MediaElch that is apparently in the community repo !

I use Filebot too.

And for 6$ per Year, its really cheap enough.

Using it with “{plex}” preset (see FAQ) wich works flawlessly with Jellyfin.

Im serious, i tried every program/script wich exists for this purpose. But no single one is so good like Filebot. And you want to use it. specially if you get “into troubles” (wrong names/title picked), with Filebot you have first a preview, and you can very easly correct that.

Only 6$ ? That’s nice and really worth it just to encourage the devs.

What do you get with the license ?

The Programm isnt free. You cant use it without license.

Without license, you can only preview what Filebot would do. But if you click to do the renaming, its say you must buy a license.

There is a Version in AUR, wich is totaly free. Wich you posted a link about. But this Version is totaly outdated and few bugs (regarding the database from tvdb and other) breaks the usability.

1 Like

Yeah, I think I’m sold on Filebot now, and I agree that it’s good to support the devs.

ggg - I’m not sure if it’s changed (you mentioned it’s been awhile since you’ve used it) but as of right now you can’t actually rename anything in Filebot without a license - It shows you what the intended changes are but won’t commit them without a license.

What am I missing?

$ echo $SHELL
/usr/bin/zsh
$ zmv
zsh: command not found: zmv

Ah ha!

$ autoload zmv
$ zmv
Usage:
  zmv [OPTIONS] oldpattern newpattern
where oldpattern contains parenthesis surrounding patterns which will
be replaced in turn by $1, $2, ... in newpattern.  For example,
  zmv '(*).lis' '$1.txt'
renames 'foo.lis' to 'foo.txt', 'my.old.stuff.lis' to 'my.old.stuff.txt',
and so on.  Something simpler (for basic commands) is the -W option:
  zmv -W '*.lis' '*.txt'
This does the same thing as the first command, but with automatic conversion
of the wildcards into the appropriate syntax.  If you combine this with
noglob, you don't even need to quote the arguments.  For example,
  alias mmv='noglob zmv -W'
  mmv *.c.orig orig/*.c
1 Like

For manual renaming, Filebot is what I have used for years. If there was an alternative out there I’d use it, but the truth is nothing else comes close for metadata matching. There are automated options if you’re running something like Sonarr or Flexget, but it requires more setup and of course with automation there will be occasional mismatching.

I had the same issue, I found some other good functions which need to be autoloader like zcalc.
You can find more here:

1 Like

Filebot was open source up until version 4.7.9, when the dev had a minor hissy fit with support reqests, closed sourced it and added a license.

The open source version is still available in the AUR as filebot47, it requires java8 to run, and it still works quite well.

1 Like