Using az sort with If then

All about user-defined episode / movie / file name format expressions
Post Reply
juzz18
Posts: 3
Joined: 29 Apr 2022, 11:33

Using az sort with If then

Post by juzz18 »

I've been playing around with the naming schemes for renaming my movies.

Came across the {az} which is handy for getting the first letter of the title but i'm trying to work out how can I encorporate if statements, to move the movies into folders, based off the file structure below.

Essentially, if the movie starts with a numeric no of 0-9 then put in the 0-9 folder. If {az} is between A-E then put it inside that folder, then the correct single letter folder below.

I could make it easier and just use the straight az and move all the A to Z folders up to the root directory, but i'd still need an if statement / naming to sort out the movies starting with 0-9. This is the main bit i'm stuck with.

Any assistance would be apprciated. Thanks.


├───0-9
├───A-E
│ ├───A
│ ├───B
│ ├───C
│ ├───D
│ └───E
├───F-J
│ ├───F
│ ├───G
│ ├───H
│ ├───I
│ └───J
├───K-O
│ ├───K
│ ├───L
│ ├───M
│ ├───N
│ └───O
├───P-T
│ ├───P
│ ├───Q
│ ├───R
│ ├───S
│ └───T

└───U-Z
├───U
├───V
├───W
├───X
├───Y
└───Z
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using az sort with If then

Post by rednoah »

e.g.

Code: Select all

{
	switch(az) {
		case 'A'..'E': return 'A-E'
		case 'F'..'J': return 'F-J'
		case 'K'..'O': return 'K-O'
		case 'P'..'T': return 'P-T'
		case 'U'..'Z': return 'U-Z'
		case '0-9': return '0-9'
		default: return '###'
	}
}

:idea: Note that {az} will return "0-9" by default (and not just a single digit) for movie / series / collection names that start with a digit.
:idea: Please read the FAQ and How to Request Help.
juzz18
Posts: 3
Joined: 29 Apr 2022, 11:33

Re: Using az sort with If then

Post by juzz18 »

rednoah wrote: 29 Apr 2022, 20:04 e.g.

Code: Select all

{
	switch(az) {
		case 'A'..'E': return 'A-E'
		case 'F'..'J': return 'F-J'
		case 'K'..'O': return 'K-O'
		case 'P'..'T': return 'P-T'
		case 'U'..'Z': return 'U-Z'
		case '0-9': return '0-9'
		default: return '###'
	}
}

:idea: Note that {az} will return "0-9" by default (and not just a single digit) for movie / series / collection names that start with a digit.
Legend. Thanks a lot for that. I'd prefer not to double up on the 0-9 folders, so I've edited / added to it to repeat a switch again but for the next folder, to determine the letter or add nothing if the az = a digit. Once I add the folder path at the start, with other naming convention stuff at the end, it seems to have done the trick.

EG:

Code: Select all

	switch(az) {
		case 'A'..'E': return 'A-E/'
		case 'F'..'J': return 'F-J/'
		case 'K'..'O': return 'K-O/'
		case 'P'..'T': return 'P-T/'
		case 'U'..'Z': return 'U-Z/'
		case '0-9': return '0-9/'
		default: return '###'
	}
}{	
	switch(az) {
		case 'A'..'Z': return az
		case '0-9': return ''
		default: return '###'
	}
Result:

/PATH/A-E/A/Avengers (A movie starting with A)

/PATH/0-9/300 (A movie starting with a digit)


Thanks again!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using az sort with If then

Post by rednoah »

juzz18 wrote: 02 May 2022, 04:53 I'd prefer not to double up on the 0-9 folders, so I've edited / added to it to repeat a switch again but for the next folder, to determine the letter or add nothing if the az = a digit.
e.g.

Code: Select all

{
	switch(az) {
		case 'A'..'E': return 'A-E' / az
		case 'F'..'J': return 'F-J' / az
		case 'K'..'O': return 'K-O' / az
		case 'P'..'T': return 'P-T' / az
		case 'U'..'Z': return 'U-Z' / az
		default: return '0-9'
	}
}
:idea: Please read the FAQ and How to Request Help.
juzz18
Posts: 3
Joined: 29 Apr 2022, 11:33

Re: Using az sort with If then

Post by juzz18 »

Yeah, or that. That's much cleaner tbh. Thanks :)
Post Reply