Page 1 of 1

Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 07 Jul 2023, 03:39
by RBCC2023
I have a file named Episodes name in text format .
The replace param may be used .
Do i assign a variable to each of the titles?
How to read the file and use the n.replace to use replace what filebot read to whats in the file
Ie:
N.replace ("The Bullwinkle show", this is from the file ) .

Jtm

Re: Call a file's contents

Posted: 07 Jul 2023, 13:06
by rednoah
e.g.

Groovy: Select all

File.getText()
:arrow: https://docs.groovy-lang.org/latest/htm ... #getText()



:idea: [Plain File Mode] Batch Rename any type of file might be start. The Rename files based on sibling XML files examples seems to be somewhat similar to your use case, though not exactly the same.

:idea: [SNIPPET] Use Custom Series Names / Force Series Name / Hardcode Series Name might be useful as well since it covers reading a map (e.g. for replacement) from an external *.tsv file.

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 08 Jul 2023, 01:52
by RBCC2023
I use TVDB and l am trying to truncate a file name from <The Bulllwinkle show - peabody's improbable history -alexander graham bell to alexander graham bell . Is there a parameter called truncate? Ie n.truncate?

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 08 Jul 2023, 07:36
by rednoah
e.g.

Format: Select all

{
	"The Bulllwinkle show - peabody's improbable history -alexander graham bell".after(/-\b/)
}

Code: Select all

alexander graham bell

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 09 Jul 2023, 22:38
by RBCC2023
If i use this line n-s00e00-t, how do Use the .after parameter if i dont know the string after the peabodys improbable history?
In the GUI. Thank you for all your help.

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 10 Jul 2023, 03:59
by rednoah
RBCC2023 wrote: 09 Jul 2023, 22:38 if i dont know the string after the peabodys improbable history?
Then the task at hand is impossible. However, presumably, you somehow know which bits and pieces you want to select & copy over, so you could start by analyzing your own thought process, and analyze what exactly allows you to know what you want and what you don't want, and then express that in code. This may or may not be feasible.

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 12 Jul 2023, 03:16
by RBCC2023
Here is the code

Code: Select all

{n}-s00e00-{t} 

n="The Bullwinkle Show "
t="fractured Fairy Tales-Repunzal"

Now I would to have it read :
Fractured Fairy Tales s01e01 Repunzal
And work for a series of files !
each shows fractured fairy tales -s01e01 -Roudolph
"" -s01e2 -Sammy
etc.,
John

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 12 Jul 2023, 04:06
by rednoah
e.g.

Format: Select all

{ t.before('-') } | { t.after('-') }
Screenshot


:!: Note that this episode is S01E02 so if you want to invent your own Series / Episode numbering by "first part of episode title" than that will likely require coding skills (i.e. custom code that groups and counts episodes via the {episodelist} or {model} bindings) that far surpass your capabilities, so unfortunately out of luck for the "make it s01e01 and so on" part:

Code: Select all

The Bullwinkle Show - 1x02 - Fractured Fairy Tales - Rapunzel
The Bullwinkle Show - 1x07 - Fractured Fairy Tales - Puss and Boots (aka Puss in Boots)
The Bullwinkle Show - 1x12 - Fractured Fairy Tales - The Enchanted Fish
...

EDIT:

:arrow: viewtopic.php?t=13812

Re: Call a file's contents (i.e. How do I read a file in Groovy?)

Posted: 12 Jul 2023, 18:25
by RBCC2023
thank you rednoah!