Different Naming Scheme Depending On Extension
Posted: 28 Jan 2015, 18:13
Before I dive into the nitty gritty of my post, I want to express my sincere gratitude for this great tool and the vast resources that are provided in this community 
I have been using it for my GUI-assisted renaming tasks in one form or another for quite a while.
Now I want to finally get rid off an old shellscript I wrote years ago and use the FileBot CLI for my automated renaming tasks as well.
What I want to accomplish
In order to contribute at least a little and give some background information, I'll post my basic naming scheme for tv series. It mainly consists of code snippets posted by rednoah, Igor and various other board users (thanks, guys
) and some slight modifications to suit my taste. The aim was similar to Igor's: straight forward, clean naming, adhering relatively close to scene standards.
I have been trying all evening to extend my naming scheme in order to handle various extensions differently, but I failed miserably. By now I think the most elegant solution would be to write/modify a FileBot script.
Here is how far I got in my naming scheme:
Once I use the matchAll function in the above expression, e.g. ${"."+fn.matchAll(/repack|proper|rerip|internal|repacked/)}, I run into trouble, as matchAll breaks if it does not find a matching pattern.
Now this was not the first time the thought occurred that there must be a more genteel solution to the task at hand than to write an overly complex naming scheme.. so before working around the issue and taking this sham any further all the while outing myself to be the biggest copy & paste & trial & error idiot on the planet, I wanted to ask how to do it right.
I am willing to work for my cake, but I would appreciate a push into the right direction
How would you experts go about solving the task outlined in #2 of my agenda?
Can it be done via naming scheme or do I have to get into scripting?
Once I get the naming based on extension sorted out, I will continue to pull out my hair regarding the creation of symlinks pointing to the moved files.
One step (and hair) at a time, though
Any help is appreciated.
Regards,
gordian

I have been using it for my GUI-assisted renaming tasks in one form or another for quite a while.
Now I want to finally get rid off an old shellscript I wrote years ago and use the FileBot CLI for my automated renaming tasks as well.
What I want to accomplish
- Rename files according to my preferences
- Use a different naming scheme depending on file extension; namely: move *.nfo and *.jpg files to a subdirectory, retaining their original filename
- Move files to folder x and create symlinks in folder y that point to the files in their new location
In order to contribute at least a little and give some background information, I'll post my basic naming scheme for tv series. It mainly consists of code snippets posted by rednoah, Igor and various other board users (thanks, guys

Code: Select all
{n.upperInitial().space('.').replaceAll(/[,()]+/).replaceAll(/\.-\./,'.')}.{s00e00}.{t.upperInitial().space('.').replacePart('Part.$1').replaceAll(/[`´‘’?]/, "'")}{"."+fn.matchAll(/unrated|uncut|extended/).join('.').lower().upperInitial()}{"."+fn.matchAll(/repack|proper|rerip|internal|repacked/).join('.').toUpperCase()}{'.'+vf.match(/720p|1080p/)}{".$source"}{"."+fn.matchAll(/DD5.1|AAC2.0/).join('.').toUpperCase()}{"."+vc.replaceAll(/AVC/, "H264")}{def g = c{group}; def m = c{fn.match(/(?:(?<=[-])\w+$)|(?:^\w+(?=[-]))/)}; if(g==null && m!=null) return "-$m"; if(g!=null) return "-$g"; if(g==null && m==null) return "-iND"}
Here is how far I got in my naming scheme:
Code: Select all
{if (ext =~ /jpg|nfo/) return "nfos/${fn}"; else return "${n.upperInitial().space('.').replaceAll(/[,()]+/).replaceAll(/\.-\./,'.')}.${s00e00}.${t.upperInitial().space('.').replacePart('Part.$1').replaceAll(/[`´‘’?]/, "'")}"}
Now this was not the first time the thought occurred that there must be a more genteel solution to the task at hand than to write an overly complex naming scheme.. so before working around the issue and taking this sham any further all the while outing myself to be the biggest copy & paste & trial & error idiot on the planet, I wanted to ask how to do it right.
I am willing to work for my cake, but I would appreciate a push into the right direction

How would you experts go about solving the task outlined in #2 of my agenda?
Can it be done via naming scheme or do I have to get into scripting?
Once I get the naming based on extension sorted out, I will continue to pull out my hair regarding the creation of symlinks pointing to the moved files.
One step (and hair) at a time, though

Any help is appreciated.
Regards,
gordian