Media Library Management

Any questions? Need some help?
Post Reply
inferusvir
Posts: 6
Joined: 10 Dec 2018, 21:02

Media Library Management

Post by inferusvir »

I've been using Filebot for a few months now, on a manual, one-by-one basis. I have a rather large library, spread over 4 nas devices. I've been looking for a way to re-organize what files are on what drives, and how they're sorted, based on type(movie, doc, tv, concert, etc) and how much available space is on each drive at the time. I've been told Filebot does this. If that is the case, I'm assuming script-based. I've been looking through the forums and a few youtube presentations, but as yet have not found anything beyond what I've already been doing (albeit in a more automated, and efficient manner).
Can I use it to re-organize & maintain my file structure as well as the file-renaming? If so, could you kindly point me in the direction of a guide/walk-through/tutorial/doc/etc?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Media Library Management

Post by rednoah »

This is all in the naming scheme, so it's the same for GUI and CLI:
https://www.filebot.net/naming.html

You will find lots of snippets that might be useful for your particular use case (check free space, keep parts of the original filename, etc) here:
viewtopic.php?f=5&t=2

e.g. organize files but take the drive letter from the current / original path:

Code: Select all

{file.path[0]}:/Media/{plex}
e.g. match certain keywords from the current / original path:

Code: Select all

{folder.path.match(/Arts and Culture|Comedy|Documentary|Drama|Game Show|Horror|Kids|Motoring|Music|Mystery|Planes and Trains|Property|Radio|Reality|Sci-Fi|Soaps|Special Events|Talkshow|Travel/)}
:idea: Please read the FAQ and How to Request Help.
inferusvir
Posts: 6
Joined: 10 Dec 2018, 21:02

Re: Media Library Management

Post by inferusvir »

I've been attempting to research and put together two scripts: one to re-sort and distribute my current library across the (currently) 4 separate NAS destinations, then another to maintain that organization.
To start with, I believe I need to customize this code snippet:

Code: Select all

{['C:', 'D:', 'E:'].collect{ (it+'/TV/'+n) as File }.sort{ a, b, c, d -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace <=> c.diskSpace <=> d.diskSpace }.last()}/{episode}
This format will always evaluate to a path to the drive with the most free space, unless the series folder already exists on one of the drives in which case it'll prefer the existing one.
If my understanding is correct, I'd need to make that into several chunks, one for each media type ie:

Code: Select all

{['W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/TV_Series/'+n) as File }.sort{ a, b, c, d -> a.exists() <=> b.exists() <=> c.exists() <=> d.exists()?: a.diskSpace <=> b.diskSpace <=> c.diskSpace <=> d.diskSpace  }.last()}/{episode}

Code: Select all

{['W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/Music/'+n) as File }.sort{ a, b,c, d -> a.exists() <=> b.exists() <=> c.exists() <=> d.exists()?: a.diskSpace <=> b.diskSpace <=> c.diskSpace <=> d.diskSpace  }.last()}/{episode}

Code: Select all

{['W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/Movies/'+n) as File }.sort{ a, b, c, d -> a.exists() <=> b.exists() <=> c.exists() <=> d.exists()?: a.diskSpace <=> b.diskSpace <=> c.diskSpace <=> d.diskSpace  }.last()}/Movies/{n} ({y})/{n} ({y})

Code: Select all

{['W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/Documentary_Movies/'+n) as File }.sort{ a, b, c, d -> a.exists() <=> b.exists() <=> c.exists() <=> d.exists()?: a.diskSpace <=> b.diskSpace <=> c.diskSpace <=> d.diskSpace  }.last()}/Movies/{n} ({y})/{n} ({y})

Code: Select all

{['W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/Documentary_Series/'+n) as File }.sort{ a, b, c, d -> a.exists() <=> b.exists() <=> c.exists() <=> d.exists()?: a.diskSpace <=> b.diskSpace <=> c.diskSpace <=> d.diskSpace  }.last()}/{episode}
Am I correct thus far?

EDIT: I just realized something: these snippets (if they're correct) would be great for the 2nd part, managing the files & folders after the re-organisation has been executed properly. It doesn't 'look' like they'd be effective for the initial re-sort.

Let me put in a little detail of what I have & what I want, then hopefully it'll be clearer and easier to get help :)
I've four 2-bay NAS units consisting of 2 pairs of 4-Tb NAS drives, 1 pair of 3Tb NAS drives and 1 pair of 2Tb Nas drives, each pair is configured to RAID1 .
Before the new year, the 2Tb drives will be replace with a new pair of 4Tb NAS drives. Each drive is mounted on a Centos7 machine with /etc/fstab & a mount -a notation in crontab. The plex server runs solo on this machine. Each of the drives is also a mapped network drive in my windows 7 Pro where my Filebot currently resides.
1 drive is about 80% full; 2 are about 60% full, and one is about 10%.
Each drive has the same root folders /Movies/, /TV_Series/, /Concerts/, /Music/, /Documentary Movies/, /Documentary Series/
The first thing I'd like to do is have all the folder & files (relatively) evenly deployed throughout the available drives.
Next would be to evaluate each folder, adding subtitles, art, etc to each.
Finally, create 2 scripts to maintain and add to the library. Both to be run automatically for each media file addition. One running on my Windows box and another to run from my wife's macbook air.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Media Library Management

Post by rednoah »

1.
Indeed, that would be bad for the initial sort, since the format is applied for all matches, before any files is moved, so all files would end up on the same drive whichever has the most disk space.


2.
The sort / comparison code is always the same, regardless of how many drives / folders you're sorting:

Code: Select all

{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }
Your code will result in an immediate error. Best to use the Format Editor GUI so you catch those right away. Do not prototype custom formats on the command-line. I can't do it, and neither can you. :lol:

Image


EDIT:

This part predicts all the possible folder paths for the series folder (i.e. [C:/TV/Firefly, D:/TV/Firefly, E:/TV/Firefly]) and then sorts that list of folders by existence (primary) and disk space (secondary)

Code: Select all

['C:', 'D:', 'E:'].collect{ (it+'/TV/'+n) as File }
So the result of this complex part of the expression is simply a file path such as "C:/TV/Firefly" and so the rest of the format doesn't have take that into account anymore. It'll be obvious if you prototype in the Format Editor and see instant feedback of the path your format generates.



3.
You can still kinda do what you want, but instead of one big initial call, you could just call filebot on each folder one after another. So files get processed and moved, using disk space, before processing the next folder, which then might go into a different drive.

Many ways to do this. find . -type d -exec works great on Linux. On Windows, I'd probably go with FileBot Scripting (i.e. the renall script might just work for you right out of the box) since CMD / PowerShell is typically pain for these things. If you're using the amc script, it might just work too, because it also processes files in batches.

TL;DR A single -rename -r call won't work, but many -rename calls one after another on one folder after another will do the trick. The amc script works out of the box because it'll process files in groups by nature.

Make sure to do --action test for testing, so you can do a dry run and see what's going on, but be aware that if no files are actually moved, then remaining disk space won't change either.
:idea: Please read the FAQ and How to Request Help.
inferusvir
Posts: 6
Joined: 10 Dec 2018, 21:02

Re: Media Library Management

Post by inferusvir »

I'm confused.
Using the GUI to move/rename, ok
declaring what format to name the particular names/folders, ok
declaring where those folders are located, NOT ok
-- entering ['H:', 'W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/Movies/'+n) as File } into the format expression gives "Binding "it": undefined"
so how do I use the GUI to tell it to go through the 5 locations.
I see {home}/{plex} would work nicely, if I wanted everything brought to the C drive, I just have no idea what to replace {home} with
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Media Library Management

Post by rednoah »

This code:

Code: Select all

{['H:', 'W:', 'X:', 'Y:', 'Z:'].collect{ (it+'/Movies/'+n) as File }}
yields this result:

Code: Select all

[H:/Movies/Firefly, W:/Movies/Firefly, X:/Movies/Firefly, Y:/Movies/Firefly, Z:/Movies/Firefly]
as explained above.


Building a complete example step by step:


Step 1: Collect movie folder candidates

Code: Select all

{['H:', 'W:', 'X:', 'Y:', 'Z:'].collect{ it + '/' + plex[0..1] }}

Code: Select all

[H:/Movies/Avatar (2009), W:/Movies/Avatar (2009), X:/Movies/Avatar (2009), Y:/Movies/Avatar (2009), Z:/Movies/Avatar (2009)]

Step 2: Find movie folder candidate that either already exists, or has the most remaining disk space

Code: Select all

{
	['H:', 'W:', 'X:', 'Y:', 'Z:']
	.collect{ it + '/' + plex[0..1] as File }
	.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }
}

Code: Select all

[H:/Movies/Avatar (2009), W:/Movies/Avatar (2009), X:/Movies/Avatar (2009), Y:/Movies/Avatar (2009), Z:/Movies/Avatar (2009)]
:idea: Now the list is sorted. I have none of these drives, so the order doesn't change. On your machine, it'll be ordered, according to existence and remaining space, the last one being the target folder you want.

Code: Select all

{
	['H:', 'W:', 'X:', 'Y:', 'Z:']
	.collect{ it + '/' + plex[0..1] as File }
	.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }
	.last()
}

Code: Select all

Z:/Movies/Avatar (2009)

Step 3: Complete the format:

Code: Select all

{
	['H:', 'W:', 'X:', 'Y:', 'Z:']
	.collect{ it + '/' + plex[0..1] as File }
	.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }
	.last()
}/{plex.name}

Code: Select all

Z:/Movies/Avatar (2009)/Avatar (2009) CD1
:idea: Please read the FAQ and How to Request Help.
inferusvir
Posts: 6
Joined: 10 Dec 2018, 21:02

Re: Media Library Management

Post by inferusvir »

Much thanks for the assistance :)
thus far, that now seems to work pretty well for whatever files are sourced elsewhere. This does not work on files already on those drives so instead of, I'll simply build on what's there. I'll scan fer subtitles, art, etc and just carry on from this point.
Post Reply