Page 1 of 1

Re-organize previously organized files using local xattr metadata

Posted: 16 Feb 2022, 14:26
by rednoah
FileBot stores xattr metadata when processing files, so you can instantly and reliably re-process files again later.

Image


GUI:
Select Fetch Data ➔ Smart Mode: Attributes when matching files or Presets ➔ Datasource: Extended Attributes when creating a Preset to use Local Xattr Mode.


CLI:
The --db xattr option can be used to instantly re-match files offline against the previously stored Movie or Episode object:

Code: Select all

--db xattr


1. Process files the 1st time and store local xattr metadata:

Code: Select all

$ filebot -rename Avatar.2009.mp4 --db TheMovieDB --output Plex --format "{plex}"
[MOVE] from [Avatar.2009.mp4] to [Plex/Movies/Avatar (2009)/Avatar (2009).mp4]

Code: Select all

$ filebot -rename Alias.1x01.mp4 --db TheTVDB -non-strict --output Plex --format "{plex}"
[MOVE] from [Alias.1x01.mp4] to [Plex/TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told.mp4]
:arrow: Plex is now our primary media root based on which we can generate arbitrary secondary media structures instantly on demand.



2. Process files into secondary structures:

e.g. mirror file structures for different naming schemes:

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --output Kodi --format "{kodi}"
[HARDLINK] from [Plex/Movies/Avatar (2009)/Avatar (2009).mp4] to [Kodi/Movies/Avatar (2009)/Avatar (2009).mp4]
[HARDLINK] from [Plex/TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told.mp4] to [Kodi/TV Shows/Alias/Season 1/Alias - 1x01 - Truth Be Told.mp4]

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --output Emby --format "{emby}"
[HARDLINK] from [Plex/Movies/Avatar (2009)/Avatar (2009).mp4] to [Emby/Movies/Avatar (2009)/Avatar (2009).mp4]
[HARDLINK] from [Plex/TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told.mp4] to [Emby/TV Shows/Alias (2001)/Season 01/Alias (2001) - S01E01 - Truth Be Told.mp4]
e.g. mirror movies by director / genre / year / etc:

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --filter "movie" --output "By Genre" --format "{genre}/{plex.name}"
[HARDLINK] from [Plex/Movies/Avatar (2009)/Avatar (2009).mp4] to [By Genre/Action/Avatar (2009).mp4]

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --filter "movie" --output "By Director" --format "{director}/{plex.name}"
[HARDLINK] from [Plex/Movies/Avatar (2009)/Avatar (2009).mp4] to [By Director/James Cameron/Avatar (2009).mp4]

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --filter "movie" --output "A-Z" --format "{az}/{plex.name}"
[HARDLINK] from [Plex/Movies/Avatar (2009)/Avatar (2009).mp4] to [A-Z/A/Avatar (2009).mp4]
e.g. mirror episodes by airdate / etc:

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --filter "episode" --output "By Airdate" --format "[{d}] {plex.name}"
[HARDLINK] from [Plex/TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told.mp4] to [By Airdate/[2001-09-30] Alias - S01E01 - Truth Be Told.mp4]
e.g. mirror 4K video files into a flat folder structure:

Code: Select all

$ filebot -rename -r Plex --db xattr --action hardlink --filter "hd =~ /UHD/" --output "4K" --format "{plex.name}"
[HARDLINK] from [Plex/Movies/Avatar (2009)/Avatar (2009).mp4] to [4K/Avatar (2009).mp4]


:idea: We use hardlinks because that will allow us to have 2 or more files that share the same data on disk, thus we can have the same file multiple times at different file paths. We get all the benefits of copying files without any of the disadvantages such as wasting disk space or having to physically copy bits on disk.