Page 1 of 1

Re: How about sharing our format expressions?

Posted: 07 Apr 2023, 12:55
by rednoah
shomidamoney wrote: 07 Apr 2023, 11:09 Let me give you a bit of context. For me whenever I get a new file, I put it into a sorting hat folder to rename and sort through the files, from there I put it into the correct places; i.e. Movies, Collections, TV Shows, etc. folders. I have a few different presets I use depending on the situation.

These are my most commonly used.

Basically it renames the file, places it into a folder with the same name, and any other parent folders like collection/season, then places it into my sorting hat folder.

Unsorted TV Shows:

Code: Select all

Sorting Hat/{ny}/Season {s}/{ny.colon(' - ')}{s00e00} - {t.colon(' - ')}{if (edition == '')'' else (' -'+{edition})} [{if (hd == 'UHD')'4k UHD' else if (hd == 'FHD')'1080p FHD' else if (hd == 'HD')'720p HD' else if (hd == 'SD')'480p SD' else ({hd})}{if (hdr == '') '' else({','+hdr})},{acf}]
Example:
From - Breaking.Bad.S02E01.1080p.BluRay.x265-RARBG
To - Sorting Hat/Breaking Bad (2008)/Season 2/Breaking Bad (2008) S02E01 - Seven Thirty-Seven [1080p FHD,AAC5.1]

Unsorted Movies - Collection:

Code: Select all

Sorting Hat/{if (collection == '') '' else (collection.colon(' - ')+'/')}{ny.colon(' - ')}/{ny.colon(' - ')}{if (edition == '')'' else (' - '+{edition})} [{if (hd == 'UHD')'4k UHD' else if (hd == 'FHD')'1080p FHD' else if (hd == 'HD')'720p HD' else if (hd == 'SD')'480p SD' else ({hd})}{if (hdr == '') '' else({','+hdr})},{acf}]
Example:
From - Avatar.2009.EXTENDED.1080p.BluRay.x265-RARBG.mp4
To - Sorting Hat/Avatar (2009)/Avatar (2009) - Extended [1080p FHD,AAC5.1].mp4

Unsorted Movies - No Collection: (sometimes I use this if I have existing collection folders; i.e. new movie in series comes out)

Code: Select all

Sorting Hat/{ny.colon(' - ')}/{ny.colon(' - ')}{if (edition == '')'' else (' - '+{edition})} [{if (hd == 'UHD')'4k UHD' else if (hd == 'FHD')'1080p FHD' else if (hd == 'HD')'720p HD' else if (hd == 'SD')'480p SD' else ({hd})}{if (hdr == '') '' else({','+hdr})},{acf}]
Example:
From - Avatar.The.Way.of.Water.2022.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR10.HEVC-CMRG.mkv
To - Sorting Hat/Avatar - The Way of Water (2022)/Avatar - The Way of Water (2022) [4k UHD,Dolby Vision,DDPDA5.1].mkv

There's prolly some things I should change but so far this seems to be good. I also have some other simple renaming ones in case I need to do an overhaul of renaming where it keeps the files in its place and just renames it.

Please provide me with any feedback, good or bad.

:!: If it works, it works, but if it works by accident without actually doing what you think the code is doing, then that could be a problem later:

Code: Select all

{if (edition == '')'' else (' - '+{edition})}
This kind of "check if empty" code doesn't actually work. The condition is never true because the result is never empty string '' because edition is either defined and valid, or errors out and stops the code flow. Please read Learn how {expressions} work and useful Helper Functions for details.


:idea: I'd rewrite your first format like so:

Code: Select all

{
	~emby
	% { ' -' + edition }
	% { ' ' + allOf{ hd.match(UHD:'4k', QHD:'1440p', FHD:'1080p', HD:'720p', SD:'480p') + ' ' + hd }{ hdr }{ acf } }
}
The {emby} format takes care of the file path and our custom code injects the additional custom information into the file path.