Help with {az} binding misbehaving

Any questions? Need some help?
Post Reply
geovolvoman
Posts: 2
Joined: 24 Feb 2019, 16:42

Help with {az} binding misbehaving

Post by geovolvoman » 25 Feb 2019, 23:41

What I'm Trying to do:
Move files from a central location to the appropriate NAS volume based on the initial letter of the show (that works)
Place the Files in Alphabetical Folders (# & A-Z) according to the Absolute First Letter of the Show (problems)
Then Place in a folder by show name (Works)
Then Sub divide into Season (Works)
Then Rename to my preferred Episode Title Format (Works)

My Expression

Code: Select all

\\{n =~ /^(?i)[0-9a-b]/ ? 'NAS-3/volume_1/' : n =~ /^(?i)[c-d]/ ? 'NAS-3/volume_2/' : n =~ /^(?i)[e-k]/ ? 'NAS-3/volume_3/':n =~ /^(?i)[l-p]/ ? 'NAS-3/volume_4/':n =~ /^(?i)[q-s]/ ? 'NAS-4/volume_1/':'nas-4/volume_2/'}TV Shows/{n =~ /^(?i)[0-9]/ ? '#':az.upperInitial()}/{n}/Season {s.pad(2)}/{s.pad(2)}-{E.pad(2)} - {t.upperInitial()}
The Problem:
The {az} binding is the only method I can see to extract the first letter of the Show NAme, but it is ignoring the Word "The" and using the first letter of the next word (and presumably such words as "a"). The drive sorting method is using the Absolute first letter just fine, but as far as I can tell you can't use functions such as {n.Left(1)} (I've tried)

Also to make matters worse, I cannot test my expressions on a representative filename (ie, an episode of "The Walking Dead") because Filebot will not allow me to change the Expression sample from Firefly (the boxes are greyed out). I can select a file and so on, but it will not change the sample from the default.

I can see a possibility of achieving this by 27 individual {n =~ /^(?i)[a-a]/ ? 'A' : n =~ /^(?i)[b-b]/ ? 'B' statements, but if there is a better way, I would prefer not to, as I intend to come back and update this expression as and when I re-organise / expand my NAS volumes and I'd rather it was easier to read.

I've scoured the forum for hours and experimented, but I'm getting nowhere. Please help

User avatar
rednoah
The Source
Posts: 15328
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with {az} binding misbehaving

Post by rednoah » 26 Feb 2019, 06:36

1.
{az} does indeed give you the initial of the sort name / collection.


2.
You can get the first letter of any String-type binding like {n} like so:

Code: Select all

{n[0]}


EDIT:

r6142 adds a convenience method so you can do this in future releases:

Code: Select all

{
	n[0].match(
		'[0-9a-b]': 'Volume 1',
		'[c-d]': 'Volume 2',
		'[e-k]': 'Volume 3'
	) ?: 'Volume Default'
}
:idea: Please read the FAQ and How to Request Help.

geovolvoman
Posts: 2
Joined: 24 Feb 2019, 16:42

Re: Help with {az} binding misbehaving

Post by geovolvoman » 07 Mar 2019, 00:13

Awesome, thanks

Post Reply

Who is online

Users browsing this forum: SirCumference and 3 guests