Code: Select all
A:Apple,
B:Banana,
S:Steak,
Groovy: Select all
map=(file contents)
return map['A']
(returns "Apple")
Code: Select all
A:Apple,
B:Banana,
S:Steak,
Groovy: Select all
map=(file contents)
return map['A']
(returns "Apple")
rednoah wrote: ↑15 Jul 2012, 09:03Format: Select all
{ def table = csv('/path/to/names.tsv') table[n] ?: n }
Console Output: Select all
$ cat ~/names.tsv Deep Space 9 DS9 How I Met Your Mother HIMYM
![]()
Will need to take a look at that. So does a csv file have to have a "tsv" extension?rednoah wrote: ↑23 Jul 2024, 03:16 You can use the csv() function to read a CSV / TSV file into a Map object.
e.g.rednoah wrote: ↑15 Jul 2012, 09:03Format: Select all
{ def table = csv('/path/to/names.tsv') table[n] ?: n }
Console Output: Select all
$ cat ~/names.tsv Deep Space 9 DS9 How I Met Your Mother HIMYM
Format: Select all
def root="P:", config="P:/FileBot/"
def maps = evaluate( new File( config+"config.txt" ) )[0]
def map = maps['DEFAULTS'] + maps['MOVIES'], folders=map['folders'], dd=map['dd'], collectionsFolder=map['collectionsFolder']
Format: Select all
(config.txt)
[[
"DEFAULTS":[
"dd":"06",
"folders":[
"01":"_01",
"02":"_02",
"03":"_03",
"04":"_04",
"05":"_05",
"06":"_06",
"E1":"_E1",
"E2":"_E2",
"E3":"_E3",
],
],
"TV":[
"talkshows":true,
],
"MOVIES":[
"collectionsFolder":"_",
]
]]
Problems.rednoah wrote: ↑23 Jul 2024, 04:21If it's more about sharing a format between GUI and CLI, then How can I use the same format in both GUI and CLI? is the way to go.
Format: Select all
{
@P:/FileBot/config.groovy
}
Format: Select all
{
@P:/FileBot/groovy-snippet.groovy
}
Format: Select all
@P:/FileBot/format-snippet.groovy
Format: Select all
def configs=include "P:/FileBot/config.groovy"
If you're using include() just to create a structured data object for your configuration, then you definitely want to use json() (and convert your configuration file to JSON syntax) instead for this particular use case.
So value.stripReleaseInfo() won't work, and need to pass a paramater?rednoah wrote: ↑23 Jul 2024, 05:04 String.stripReleaseInfo(boolean strict) does exist. There is no parameterless method of that name though.
Doesn't that make it more complicated with having to use {}'s and []'s?
Yep, must pass a parameter:
Format: Select all
{
'[ONe]_Ano_Hana_01_(1280x720)'.stripReleaseInfo(false)
}
Format: Select all
{
'[ONe]_Ano_Hana_01_(1280x720)'.clean()
}
Groovy syntax is definitely more complicated than JSON syntax, because the former does a lot more, and the latter is just meant to be a simple structured data notation. That said, you can use whatever works best for you.
I'm tweaking and cleaning my expressions with the idea of sharing them. Want them to be simple include a few features that can benefit others. Such as being able to more or less "copy/paste" parts of it and only altering a few values to customize it for their use. So trying to keep it as simple as possible (the external file that will have the editable values). I figure it can also help others with making their own expressions by giving them ideas on how to do different things.
Groovy: Select all
/\d/
Groovy: Select all
"\\d"
Format: Select all
{ "12345" ==~ /\d+/ }