[CLI] Plain File Mode naming based on nearby NFO files

Support for Ubuntu and other Desktop Linux distributions
Post Reply
Retrorat1
Posts: 7
Joined: 24 Feb 2021, 07:23

[CLI] Plain File Mode naming based on nearby NFO files

Post by Retrorat1 »

Hi,
Been searching for a while now and cant figure out how to get this done.

Running a Linux headless system and want to be able to rename sports media.
example
Rename- EPL 2019 TeamA vs TeamB 15 02 720pEN60fps Prov.mkv
to
English Premier League 15-02-2019 TeamA vs TeamB 720pEN60fps Prov.mkv

Have found a sports database https://www.thesportsdb.com/ which does nfo data so have been using that with this script

Code: Select all

{
def i = xml(folder / fn + '.xml')
	[i.showtitle, i.aired, i.title].join(' - ')
}
on the windows machine but didn't know how to implement it on the Linux machine .

So if anyone can please point me in the right direction for either directly renaming or how to use the nfo information it would be greatly appreciated.
Thanks
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: New to CLI

Post by rednoah »

What have you tried so far? Where are you stuck? As far as your custom format is concerned, it will work on Linux just as it does on Windows, unmodified.


:arrow: Please read Plain File Mode for details and command-line examples.
:idea: Please read the FAQ and How to Request Help.
Retrorat1
Posts: 7
Joined: 24 Feb 2021, 07:23

Re: [CLI] Plain File Mode naming based on nearby NFO files

Post by Retrorat1 »

Hi Thanks
But when ever I try and call the command I get this

Code: Select all

def i = xml(folder / fn + '.xml')
-bash: syntax error near unexpected token `('
&

Code: Select all

 [i.showtitle, i.aired, i.title].join(' - ')
-bash: syntax error near unexpected token `('
I use

Code: Select all

 filebot {
def i = xml(folder / fn + '.xml')
	[i.showtitle, i.aired, i.title].join(' - ')
}
Thats where I get stuck
Thanks
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [CLI] Plain File Mode naming based on nearby NFO files

Post by rednoah »

Sorry, not even remotely close. Depending on your programming experience, the learning curve for this one might be rather steep I'm afraid. I'd recommend using the GUI to prototype your custom plain file format first. Playing with custom formats in the format editor allows you to play and experiment so that you can more easily grasp the concepts at play.



:arrow: As for specific advice, the following example use cases illustrate aspects of what you're trying to do. If you understand both of them, then you will be able to build something for your specific needs.



:idea: You'll want to learn general filebot usage and plain file --format option usage from this example:
rednoah wrote: 13 Oct 2014, 21:47 Organize files based on information present in the file path

You can use Groovy code and regular expressions to extract pieces of information from the file path, and then use those pieces to generate a new file path.

Code: Select all

{
	def n = folder.dir.name
	def s = folder.name.before(/[.]/)
	def c = folder.name.after(/[.]/)
	def e = fn.before(/[.]/)
	def t = fn.after(/[.]/)

	"$n/Season $s - $c/$n - S${s.pad 2}E${e.pad 2} - $t"
}
Image


:idea: You'll want to learn how to generate file names based on nearby XML files from this example:
rednoah wrote: 13 Oct 2014, 21:47 Rename files based on sibling XML files

In your format you have access to other files or web resources so you can easily build powerful rename logic for your own unique use cases. :ugeek:

Let's assume a file structure where each media file is accompanied by an XML metadata file:

Code: Select all

name.cbz
name.xml
e.g. name.xml

Code: Select all

<ComicInfo>
	<Title>Ask Not</Title>
	<Series>The American Way</Series>
	<Number>1</Number>
</ComicInfo>
Generate the desired file path based on the information in the sibling XML file:

Code: Select all

{
	def i = xml(folder / fn + '.xml')
	[i.Series, i.Number, i.Title].join(' - ')
}

Code: Select all

The American Way - 1 - Ask Not
:idea: Please read the FAQ and How to Request Help.
Retrorat1
Posts: 7
Joined: 24 Feb 2021, 07:23

Re: [CLI] Plain File Mode naming based on nearby NFO files

Post by Retrorat1 »

Thank you for your help, but unfortunately my programming skills are practically non existent .
Ill just have to download it here first then upload it to my sever.
Once again thanks for the help.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [CLI] Plain File Mode naming based on nearby NFO files

Post by rednoah »

Retrorat1 wrote: 20 Aug 2021, 10:37 Thank you for your help, but unfortunately my programming skills are practically non existent .
Ill just have to download it here first then upload it to my sever.
Once again thanks for the help.
Sorry, yeah, in that case, these kinds of custom use cases can be rather daunting. No worries.
:idea: Please read the FAQ and How to Request Help.
Post Reply