[AMC] Custom File Struture for Audio files

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

[AMC] Custom File Struture for Audio files

Post by gplans »

I have just setup Filebot on my Synology NAS.

I have automated it so that every night it will change the names of the files I place in a particular directory. It them renames them and puts the movies in the movie forder etc.

What I want to do is make the audiobooks go into a audiobook folder not the music folder. All the audiobooks have the extension .m4b.

Can this be done?

Thanks
User avatar
rednoah
The Source
Posts: 20328
Joined: 16 Nov 2011, 08:59

Re: Synology Node File Struture

Post by rednoah »

Yes, but I'm not sure if FileBot Node (i.e. amc script) is the way to go. Perhaps a custom --def musicFormat will do if things are already working and you just want to customize the destination file structure.

In general, Plain File Mode might be more suitable for processing audio files and generating file paths based MediaInfo properties.
:idea: Please read the FAQ and How to Request Help.
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

Maybe I am not that technical. I was hoping for a straightforward solution for making my filebot node on my Synology to send audiobooks into a audiobook folder and music into the music folder automatically every night.
User avatar
rednoah
The Source
Posts: 20328
Joined: 16 Nov 2011, 08:59

Re: [AMC] Custom File Struture for Audio files

Post by rednoah »

gplans wrote: 28 Sep 2021, 22:26 I was hoping for a straightforward solution for making my filebot node on my Synology to send audiobooks into a audiobook folder and music into the music folder automatically every night.
That would require a custom music format that generates audiobook file paths for some audio files and music file paths for other audio files. Notably, you'd need to express in code how to tell apart audiobook files and music files.


:idea: The default music format is the {plex} format which generates files paths akin to this:

Code: Select all

Music/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}

:idea: If we were to assume that audio files longer than 20 minutes are audio books, and not music tracks, and then just switch out the Music folder name in that case, then things will get very straightforward:

Code: Select all

{ minutes >= 20 ? 'AudioBooks' : 'Music' }/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
:idea: Please read the FAQ and How to Request Help.
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

This code does not seem to work all the time. For some reason I am having to take out hundreds of books out of the music folder. Is there a way to look for the file extension .m4b instead of a file that is longer than 20min?

Code: Select all

{ minutes >= 20 ? 'AudioBooks' : 'Music' }/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
Thanks
G
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

I have tried this bit it does not seem to work.

Code: Select all

{ ext >= m4b ? 'AudioBooks' : 'Music' }/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
kim
Power User
Posts: 1209
Joined: 15 May 2014, 16:17

Re: [AMC] Custom File Struture for Audio files

Post by kim »

Learn how works:
https://groovy-lang.org/operators.html

Code: Select all

>=	greater than or equal
try in GUI

Code: Select all

{ ext >= m4b }

Code: Select all

groovy.lang.MissingPropertyException: No such property: m4b for class
make m4b a string value in order to compare

Code: Select all

{ ext >= 'm4b' }
but >= makes no sense so

Code: Select all

{ ext == 'm4b' ? 'AudioBooks' : 'Music' }
e.g. ext = 'm4b' or ext = 'mp3'
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

So the code works great now. It will now identify the audiobooks with the extension with m4b and put them in the correct folder. But now I have two TV Shows in there and it fails every time. Is this something that I did with adding this code? If I use Filebot on my PC it will identify and rename the files but Filebot Node seems to fail. The two files are Fear.the.Walking.Dead.S07E02.Six.Hours.720p.REPACK.AMZN.WEB-DL.DDP5.1.H.264-NTb & insecure.s05e01.720p.web.h264-ggwp

This is the error when it fails.

Code: Select all

Run script [dev:amc] at [Wed Oct 27 09:21:42 PDT 2021]
Parameter: music = y
Parameter: subtitles = eng
Parameter: clean = y
Parameter: skipExtract = y
Parameter: musicFormat = { ext == 'm4b' ? 'AudioBooks' : 'Music' }/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
Parameter: excludeList = .excludes
Argument[0]: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks
Use excludes: /volume1/Media/.excludes (2)
Ignore hidden: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/.DS_Store
No files selected for processing
Done ¯\_(ツ)_/¯
User avatar
rednoah
The Source
Posts: 20328
Joined: 16 Nov 2011, 08:59

Re: [AMC] Custom File Struture for Audio files

Post by rednoah »

Are the files in the input folder you have specified?

Code: Select all

Argument[0]: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks
Are the files not on the exclude list you have specified?

Code: Select all

Use excludes: /volume1/Media/.excludes (2)
:idea: Please read the FAQ and How to Request Help.
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

Yes the files are in the directory.

Image

No I don't think it would be. Where is the list? These file have been changed recently.
kim
Power User
Posts: 1209
Joined: 15 May 2014, 16:17

Re: [AMC] Custom File Struture for Audio files

Post by kim »

looks like you used this on the files before:

Code: Select all

{ minutes >= 20 ? 'AudioBooks' : 'Music' }/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
use this to only rename/move audio files:

Code: Select all

{ f.isAudio() ? allOf{ ext == 'm4b' ? 'AudioBooks' : 'Music' }{'/' + n + '/'}{album + '/'}{pi.pad(2) + '. '}{artist}{' - ' + t}.join() : fn }
User avatar
rednoah
The Source
Posts: 20328
Joined: 16 Nov 2011, 08:59

Re: [AMC] Custom File Struture for Audio files

Post by rednoah »

The file is where it says it is in the log. Note that the leading . in the file name means that it's possibly a hidden file.
:idea: Please read the FAQ and How to Request Help.
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

That seems to have fixed the issues except the one TV show it just ignores. insecure.s05e01.720p.web.h264-ggwp.mkv

Any idea?

Thanks

Code: Select all

Run script [dev:amc] at [Thu Oct 28 11:24:19 PDT 2021]
Parameter: music = y
Parameter: subtitles = eng
Parameter: clean = y
Parameter: skipExtract = y
Parameter: musicFormat = { f.isAudio() ? allOf{ ext == 'm4b' ? 'AudioBooks' : 'Music' }{'/' + n + '/'}{album + '/'}{pi.pad(2) + '. '}{artist}{' - ' + t}.join() : fn }
Parameter: excludeList = .excludes
Argument[0]: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks
Use excludes: /volume1/Media/.excludes (1)
Ignore hidden: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/.DS_Store
Input: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/Lee Child - Better off Dead.m4b
Group: {Music=/volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks} => [Lee Child - Better off Dead.m4b]
Rename music using [ID3 Tags]
[MOVE] from [/volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/Lee Child - Better off Dead.m4b] to [/volume1/Media/AudioBooks/Lee Child/Better off Dead/01. Lee Child - Better off Dead.m4b]
[REFRESH] Refresh File Services (/volume1/Media/AudioBooks/Lee Child/Better off Dead)
[REFRESH] Refresh File Services (/volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks)
Processed 1 file
Clean clutter files and empty folders
Keep /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/insecure.s05e01.720p.web.h264-ggwp.mkv (not clutter)
Keep /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks (root folder)
Done ヾ(@⌒ー⌒@)ノ

------------------------------------------

[Process completed]
User avatar
rednoah
The Source
Posts: 20328
Joined: 16 Nov 2011, 08:59

Re: [AMC] Custom File Struture for Audio files

Post by rednoah »

The file you mentioned doesn't seem to exist:

Code: Select all

Argument[0]: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks
Use excludes: /volume1/Media/.excludes (1)
Ignore hidden: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/.DS_Store
Input: /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/Lee Child - Better off Dead.m4b
If there's no Input: ...line for that file in the log, then it's not part of the Input file set, either because it's not there, or because it's on the exclude list, and I'm not aware of any other possible explanations:

Code: Select all

Input: ...
:idea: Please read the FAQ and How to Request Help.
gplans
Posts: 13
Joined: 26 Mar 2013, 17:12

Re: [AMC] Custom File Struture for Audio files

Post by gplans »

So the file is there. As you can see in the image a bunch of files were put in the audiobook folder but again the TV show and one audiobook were left behind. They say (not clutter) and I am unsure what this refers to.

Image
User avatar
rednoah
The Source
Posts: 20328
Joined: 16 Nov 2011, 08:59

Re: [AMC] Custom File Struture for Audio files

Post by rednoah »

You're using --def clean=y to delete left-behind files; luckily there's a sanity check that prevents this file from being deleted:

Code: Select all

Clean clutter files and empty folders
Keep /volume1/Media/FileBotIn/Erins-imac.local/Users/estrench/Desktop/Audiobooks/insecure.s05e01.720p.web.h264-ggwp.mkv (not clutter)

I have no idea why the file isn't consider as input, but there are only so many conditions, and most of them print some kind of reason, so it has to be one of the conditions that don't print anything:
https://github.com/filebot/scripts/blob ... roovy#L199


:?: I don't see what you see, but there's still 1 line in the exclude list, and 1 file that's mysteriously ignored, so maybe you can try not using an exclude list at all for the sake of testing to confirm or eliminate that as a reason?

Code: Select all

Use excludes: /volume1/Media/.excludes (1)
:idea: Note that the exclude list contains file paths, but FileBot will then exclude all files by file id, i.e. all hardlinks of the given file path.
:idea: Please read the FAQ and How to Request Help.
Post Reply