Moving to a specific folder/drive

Any questions? Need some help?
Post Reply
BIZARRE
Posts: 5
Joined: 12 Sep 2014, 12:37

Moving to a specific folder/drive

Post by BIZARRE »

Hi guys, first post so please be gentle, I'd consider myself a n00b when it comes to filebot and it's automation and regexes/groovy code. Recently I've discovered its ability to move files to folders and then a specific disk based on the folder name using this example:

Code: Select all

{n =~ /^(?i)[0-9a-f]/ ? 'X' : n =~ /^(?i)[g-t]/ ? 'Y' : 'Z'}:/TV/{n}/{episode}
Now I've adapted it to take into account that I sort "The" to the end of folder names giving me this:

Code: Select all

{n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/) =~ /^(?i)[0-9a-f]/ ? 'X' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/) =~ /^(?i)[g-t]/ ? 'Y' : 'Z'}:/TV/{n}/{episode}
but now I've run into a further problem with the sorting, I need to be able to split the letter "S" into to different folders depending on the next letter in the word. For example if the series name began with Sa-Sm (i.e. Salem to Smallville) I need it to go to drive 1 and if it was So-Sz (i.e. Some Girls to Survivors) I need it to go to drive 2. I've been trying for hours to get it right, using various combinations of the lookahead command but I just can't seem to get it right. What am I missing out on/doing wrong?

Here is my actual code:

Code: Select all

{n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/) =~ /^(?i)[0-9a-d]/ ? 'D:/Videos/TV Series/Part 1' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/) =~ /^(?i)[e-i]/ ? 'D:/Videos/TV Series/Part 2' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/) =~ /^(?i)[j-r]/ ? 'D:/Videos/TV Series/Part 3' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/) =~ /^(?i)[s-z]/ ? 'D:/Videos/TV Series/Part 4' : ''}
Thanks for any help you guys can give me, it is seriously appreciated.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Moving to a specific folder/drive

Post by rednoah »

Observe:

Code: Select all

{switch(n.sortName()) { case ~/(?i)[0-9a-f].*/: return 'A-F'; case ~/(?i)S[o-z].*/: return 'So-z'; default: return 'X-Z'}}
:idea: Please read the FAQ and How to Request Help.
BIZARRE
Posts: 5
Joined: 12 Sep 2014, 12:37

Re: Moving to a specific folder/drive

Post by BIZARRE »

Rednoah thank you very much, that's solved my puzzle. Now to learn more about how and why it works.....
Post Reply