Page 1 of 1
[CLI] Plain File Mode naming based on nearby NFO files
Posted: 17 Aug 2021, 08:39
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
Re: New to CLI
Posted: 17 Aug 2021, 12:43
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.
Please read
Plain File Mode for details and command-line examples.
Re: [CLI] Plain File Mode naming based on nearby NFO files
Posted: 20 Aug 2021, 08:32
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
Re: [CLI] Plain File Mode naming based on nearby NFO files
Posted: 20 Aug 2021, 10:07
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.
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.
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"
}
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.
Let's assume a file structure where each media file is accompanied by an XML metadata file:
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(' - ')
}
Re: [CLI] Plain File Mode naming based on nearby NFO files
Posted: 20 Aug 2021, 10:37
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.
Re: [CLI] Plain File Mode naming based on nearby NFO files
Posted: 20 Aug 2021, 10:49
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.