Reapply xattr for already renamed/sorted media

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
joegoldman
Posts: 6
Joined: 12 Mar 2018, 03:36

Reapply xattr for already renamed/sorted media

Post by joegoldman »

Hi All,

I have a pretty good DB of shows - I used Filebot to organise most of it, and its already scanned into plex etc.

I did have to move all the files between NAS's at some point, and a lot of the shows at that point seemed to have dropped their xattr's (likely due to one of the FS not supporting it)

Unfortunately this really screws with the fn:miss script, as it gets in a folder and just says DONE because it has 0 episodes with xattr to get context from.

What I'd like to do is basically run renaming over it again, and have it process the files just to add the correct xattr's so that fn:miss can work properly.

I tried to run it with action MOVE and conflict as override, so it'd basically just renaming to itself but in the process applying xattr, but it ALWAYS just says skipped - file exists.

The only other option I see is basically renaming the show name folder to a temporary name, run the rename so it has to create the directory structure again but will apply the xattr's this time, but I dont really want to do this over a multi TB database, so was really hoping for a script I can just run over existing files to update xattr.

Thanks in advance for any help offered.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Reapply xattr for already renamed/sorted media

Post by rednoah »

joegoldman wrote: 12 Mar 2018, 03:43 The only other option I see is basically renaming the show name folder to a temporary name, run the rename so it has to create the directory structure again but will apply the xattr's this time, but I dont really want to do this over a multi TB database, so was really hoping for a script I can just run over existing files to update xattr.
How is using a temporary folder a problem? Checking whether a file exists or not takes no more or less effort and time for a computer than than moving a file on the same filesystem, so moving files into a new structure on the same drive won't take more time then what you have already tried.


e.g. use this format for both movies and TV shows:

Code: Select all

X:/New Plex/{plex}

Then drop in everything from your old X:/Plex folder and then process everything via Autodetect. Since you already have Movies / TV Shows folders, the Autodetect matcher will be able to auto-detect the type of media instantly and accurately.


I also recommend using Strict mode. Just in case. So you don't end up with an odd bad match every few ten thousand files:
viewtopic.php?f=3&t=4695
:idea: Please read the FAQ and How to Request Help.
joegoldman
Posts: 6
Joined: 12 Mar 2018, 03:36

Re: Reapply xattr for already renamed/sorted media

Post by joegoldman »

Just will take a lot more manual time to do that selectively, and I dont know how filebot will go if I just go filebot -r on a folder containing 100 titles with over 10k episodes combined, i accidentally ran it on the my tmp Torrent folder once and it took 5 minutes minimum for me just to cancel it let alone let it run through.
joegoldman
Posts: 6
Joined: 12 Mar 2018, 03:36

Re: Reapply xattr for already renamed/sorted media

Post by joegoldman »

I also worry if I may have hit some shows as DVD order or some other custom solution vs normal, so I'd have to figur ethem out and single them out so they dont rename wrong title based on the SxxExx - where-as if I'm just doing xattr there's little chance of screwing with title / file name.

What is the point of --conflict override if it still skips when the file exists? From what I've read online my solution for using override should have worked?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Reapply xattr for already renamed/sorted media

Post by rednoah »

1.
Why would you select anything manually? If you use Strict mode, then it'll never ask you about anything, and even in Opportunistic mode you can just enable Repeat (bottom-right toggle) the first time around and it'll auto-select everything from then on.


2.
If you have episodes that are in Airdate order and DVD order (and don't have them in separate folders to process them separately) then you're out of luck and some episodes will most certainly get mismatched. Strict mode won't help you here either.


3.
Processing all your files will take a very long time. FileBot will have to match each and every file with online episode and movie data to process it and write that information to xattr. That's why the miss script only works with xattr where this data is readily and immediately available. Full metadata can't just be conjured up from the file path.

Here's what xattr metadata looks like:
viewtopic.php?t=324#p27518


4.
--conflict override will ensure that the destination file is deleted so that the source file can be moved. You do not want to delete the destination file if the destination file is the same as the source file. :lol:
:idea: Please read the FAQ and How to Request Help.
joegoldman
Posts: 6
Joined: 12 Mar 2018, 03:36

Re: Reapply xattr for already renamed/sorted media

Post by joegoldman »

rednoah wrote: 12 Mar 2018, 04:16 1.
Why would you select anything manually? If you use Strict mode, then it'll never ask you about anything, and even in Opportunistic mode you can just enable Repeat (bottom-right toggle) the first time around and it'll auto-select everything from then on.
I do all this via CLI - not all folders need this treatment just some, and if I could only reapply xattr then I dont run the risk of renaming episodes. I also tend to use -mode interactive to review what its about to do before letting it do it. My main reason for not doing it all at once was mostly on if it could handle that many episodes without crapping out.
2.
If you have episodes that are in Airdate order and DVD order (and don't have them in separate folders to process them separately) then you're out of luck and some episodes will most certainly get mismatched. Strict mode won't help you here either.
I think I have at least 1 show in DVD order but im not sure i'll just have to check.


Thanks for the response and insight - I think my personal best solution is:

Run fn:miss on each Show folder (into temporary file), I can script this easily so it does it in the background.
Then compare all the temporary files in their relevant directories, if it just has 'DONE' then I know it picked up 0 episodes and that folder will need to be fixed
Rename the folder and run filebot on it manually
Then I can go back to running fn:miss with log off and get output of just missing episodes and fix that on a per show basis.

Probably only take me an afternoon but if the need ever arises to copy/restore from any form of backup media and it strips xattr again I just thought it'd be cool to have a script I could run on a whole DB to just re-apply them based on folder/episode name context, without risk of it renaming the folder/filename. One day I may get in and learn filebot scripting and write it myself - if I end up doing that i'll be sure to share it with the community.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Reapply xattr for already renamed/sorted media

Post by rednoah »

1.
I see. You hadn't mentioned that you're using the CLI with --mode interactive. What OS are you using? Are you processing files remotely via SSH? If possible, I recommend using the GUI when processing a large number of files manually.


2.
Why not just import/export xattr metadata to normal files?

e.g. a simple script that reads raw xattr metadata and writes it to an external file:

Code: Select all

args.getFiles().each{ f ->
	def m = f.xattr['net.filebot.metadata']

	if (m) {
		println m.saveAs(f + '.metadata.json')
	}	
}
You can do the same with bash and standard Unix tools for reading/writing xattr and store file/xattr pairs in whatever way you prefer. ;)


:idea: Reprocessing files requires looking at and interpreting each file again, so it's extremely slow and error prone compared to just storing and restoring a few bits and bytes, so retagging files by processing them again makes no sense. ;)
:idea: Please read the FAQ and How to Request Help.
Post Reply