MediaElch icon indicating copy to clipboard operation
MediaElch copied to clipboard

Improved File Renamer

Open bugwelle opened this issue 6 years ago • 12 comments

This was originally requested on the old MediaElch forum

It would be great if you could consider improving the file renaming tool in MediaElch to include the following features:

  1. Rename at the moment of scraping info (not in two separate tools, actions)
  2. Rename files and folders at the same time (starting with files, ending with folders)
  3. Include episode name (according to scrapper selected) in a file and/or folder renaming
  4. Adding a custom suffix (IE: 1080p.WEB-DL.EAC3-5.1.x264)
  5. The option to replace "spaces" with "periods"
  6. Be able to remove diacritics in files name and folders name

Other feature requests:

  • from #592: It would be nice if we can rename files all in lower- or uper case. For logical reasons with a new placeholder in the rename window.
  • #582

bugwelle avatar May 21 '18 15:05 bugwelle

Personally I really like tinyMediaManager's renamer:

tmm renamer

bugwelle avatar Feb 20 '19 11:02 bugwelle

Suggestions for a new renamer

Movies

Key-Types

  • Title: String without newlines
  • Overview: String with newlines
  • Year: Number
  • 3D: Bool
  • Movieset: Object with sub-keys, e.g. movie set

Modifiers

Given title: "Big Buck Bunny (2008), 10min, Rating: 9.768"

Type Key Example
String ${title} Big Buck Bunny
Substring ${title:3 } Big
Character ${title[0]} B
String Literal my string, ${"my string"} my string
Bool ${3D ? ${title} } Big Buck Bunny or empty
Bool with alternative ${3D ? ${title} : "no-3d" } Big Buck Bunny or no-3d
Integer ${year} 2008
Integer: left pad with 0 ${minutes:4} 0010
Float ${rating} 9.65 (default: width=2)
Float + width ${rating.2} 9.6

Rules

  • Spaces are ignored inside ${...}
  • "Variables" are inside ${}
  • Format options are separated by :
  • Access options (e.g. character) are inside []
  • conditions use ? and :

Alternative: http://mustache.github.io would be good idea as well work in progress

bugwelle avatar Feb 20 '19 12:02 bugwelle

Hello! A little something that bothers me with some non-english languages: trailing spaces. For example if the title of a movie is "Quoi de neuf ?", the filename will be "Year - Quoi de neuf .avi".

The problem doesn't appear in english where there is no spaces in front of double punctuations.

Did I miss how to set the renamer to exclude those trailing spaces or do you need to fix the code?

Thank you for all the work!

Stis avatar Jan 10 '21 13:01 Stis

Must be fixed on our side. Thanks for reporting. :-)

bugwelle avatar Jan 10 '21 14:01 bugwelle

Ok, nice. I can't wait the update! ;)

Stis avatar Jan 10 '21 16:01 Stis

Hi,

This look like a nice improvement.

I try to organize movies by genres folders, can you also support the "genre" tag too please ?

It's a little different from the studio implementation since here we probably only need to use the first tag, so the template implementation is needed.

For now, the genre tags seem to be arranged in alphabetical order, so maybe in the long run a possibility to reorder them manually?

silvus avatar Sep 04 '21 17:09 silvus

Hello. Back then I edited all my files by hand, even if I'm pretty sure I did some tests.

In 2.8.2 I see the old behaviour, trailing spaces remain. Since 2.8.4 it's ok, they're removed. BUT not totally.

If

is "Quoi de neuf ", yes, this trailing space will be removed and the filename be "Quoi de neuf.ext" If <title> is "Quoi de neuf ? ", so the trailing spaces will be removed, then the final interrogation point will be too since it can't be in a filename, then my filename will be "Quoi de neuf .ext" <p>With all my files edited by hand, I just re-encountered this problem now. ^^'</p>

Stis avatar Nov 11 '22 16:11 Stis

hmm.. That shouldn't happen. sanitizeFilename() removes trailing/leading whitespace last, after replacing the ?. Thanks for reporting!

bugwelle avatar Nov 17 '22 17:11 bugwelle

I will try to improve the renamer this year. I will use this issue as a log for personal notes, etc. If you don't want notifications, you can disable them via GitHub (on the right side in this issue).

bugwelle avatar May 25 '23 15:05 bugwelle

I write about a new concept here a bit: https://github.com/Komet/MediaElch/pull/1576 Feel free to add comments. It's work in progress.

bugwelle avatar May 27 '23 09:05 bugwelle

Another one for the wishlist:

A "search and replace" type function to manually strings to replace. As an example I have several TV series with external subtitles, however they aren't recognised by Jellyfin because they are using a "wrong" format:

$ ls -1
rsg-fargo-s01e02-1080p-eng.idx
rsg-fargo-s01e02-1080p-eng.sub
rsg-fargo-s01e02-1080p-forced.idx
rsg-fargo-s01e02-1080p-forced.sub
rsg-fargo-s01e02-1080p.idx
rsg-fargo-s01e02-1080p.mkv
rsg-fargo-s01e02-1080p.sub

Notice the - in the filename as a separator at the end, but Jellyfin requires a . to separate these flags: https://jellyfin.org/docs/general/server/media/external-files#naming-flags

Ideally the renamer could grab the language identifier from the idx file and apply it to both idx and sub, but since that would presumably require a lot more work, it would be nice to at least be able to replace -eng with .eng, and -forced with .forced (or .ger.forced in this case).

edit: On that note, it might be cool to have these external files listed in the Stream Details tab so the user can adjust those flags (whether that be a selection field or free-form-input).

I also forgot to mention this should also apply to External Audio Tracks, which currently aren't picked up at all:

$ ls -1 | grep S01E01
S01E01.ac3
S01E01.mkv
S01E01.nfo

image

edit: I just noticed there is already an issue for this: #1044

I don't know how the Renamer currently picks files to rename but it seems to me like a lot of special case handling. I might be wrong on this but I feel like a shotgun approach wouldn't actually be bad in this case, i.e. just getting the current filename (minus extension) and grabbing every single filename that starts with that same string. That way ME doesn't need special handling for specific filetypes or care about suffixes in the filename at all and users can throw any kind of file they like at it, as long as ME preserves the suffixes. I currently do some of that with sed where I just swap out specific parts of the filename that I need.

mihawk90 avatar Dec 03 '23 22:12 mihawk90

Notes to self: https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations

bugwelle avatar Dec 23 '23 17:12 bugwelle