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

Support for Windows users
Post Reply
RBCC2023
Posts: 6
Joined: 07 Jul 2023, 02:17

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

Post 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
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Call a file's contents

Post 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.
:idea: Please read the FAQ and How to Request Help.
RBCC2023
Posts: 6
Joined: 07 Jul 2023, 02:17

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

Post 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?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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
:idea: Please read the FAQ and How to Request Help.
RBCC2023
Posts: 6
Joined: 07 Jul 2023, 02:17

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

Post 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.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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.
:idea: Please read the FAQ and How to Request Help.
RBCC2023
Posts: 6
Joined: 07 Jul 2023, 02:17

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

Post 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
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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
:idea: Please read the FAQ and How to Request Help.
RBCC2023
Posts: 6
Joined: 07 Jul 2023, 02:17

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

Post by RBCC2023 »

thank you rednoah!
Post Reply