How to write a custom xattr tag to files?

Any questions? Need some help?
Post Reply
DoctorBubba
Posts: 15
Joined: 17 Jan 2023, 14:21

How to write a custom xattr tag to files?

Post by DoctorBubba »

I've been pouring over this for an hour trying to figure it out but I'm not getting anywhere. I've mostly been looking at this topic: viewtopic.php?t=4826 but I can't make any commands that work.

All I want to do is tag my files with a label to identify their origin, mostly torrent trackers but it could be something like YouTube or archive.org.

I plan to write a bash script to add this xattr tag to all of my files as they come in. They can get the name of the tracker from the folder they're in as that's how I have them sorted initially.

A couple of the things I've tried that haven't worked:

This one seems to execute and says done, but then if I open the files in FileBot GUI, go to filters, select the files and go to the attributes tab, there is nothing there:

Code: Select all

filebot -r '/storage/Temporary/' -script "g:args.each{ it.xattr[key] = value }" --def key="net.filebot.test" --def value="Hello World"
This one returns 'Bad script source: f.xattr['net.filebot.ut.label'] = 'Label 1'':

Code: Select all

filebot -script "f.xattr['net.filebot.ut.label'] = 'Label 1'" -r '/storage/Temporary/The Smurfs'
I'm sorry for so many questions but I'm having a lot of trouble figuring out this part. It seems that writing xattr attributes is pretty advanced, but I just want to do something simple with it.

Thank you!
User avatar
rednoah
The Source
Posts: 23073
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to write a custom xattr tag to files?

Post by rednoah »

:?: Which OS are you using?


:arrow: You can read/write xattr / NTFS Alternate Data Streams with standard system tools, e.g. Set-Content on Windows, xattr on macOS, setfattr on Linux, setextattr on BSD, etc.


:!: The Filter ➔ Attributes table will only show you FileBot xattr metadata such as Movie / Episode Object and Original Name. The FileBot Desktop application cannot be used to view or modify 3rd party xattr key/value pairs.


:arrow: You can use the xattr script to view all xattr / NTFS Alternate Data Streams:

Code: Select all

filebot -script fn:xattr /path/to/files
EDIT: The xattr script will show all xattr but only for files that have FileBot xattr metadata. The xattr script may ignore files without FileBot metadata even if there are some 3rd party key/value pairs.


:!: The xattr script notably does not support writing custom xattr key/value pairs.



EDIT:

The xattr script has been updated to better support read/write of 3rd party xattr key/value pairs:
https://github.com/filebot/scripts/comm ... ttr.groovy
:idea: Please read the FAQ and How to Request Help.
DoctorBubba
Posts: 15
Joined: 17 Jan 2023, 14:21

Re: How to write a custom xattr tag to files?

Post by DoctorBubba »

I'm using the Docker container on UnRaid.

Okay, so I was successfully writing the xattr data, I just can't see if from the GUI.

I tested and it looks like I can rename a file using this data by putting this in the format for that file:

Code: Select all

{f.xattr['net.filebot.test']}
That's what I needed to do. When I do the final rename on the files with FileBot, I'm going to add the origin to the end of the files.

What is the benefit for defining a key as, "net.filebot.test" when it's possible to just use "test"?

Thank you very much for all of your help! This program is so extremely powerful, which means it takes a lot of work to get the most out of it, but it's worth it.
User avatar
rednoah
The Source
Posts: 23073
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to write a custom xattr tag to files?

Post by rednoah »

DoctorBubba wrote: 18 Mar 2023, 15:38 What is the benefit for defining a key as, "net.filebot.test" when it's possible to just use "test"?
There is no benefit for you. FileBot uses net.filebot.metadata and not metadata because the latter may very well already used by some other piece of software.
:idea: Please read the FAQ and How to Request Help.
Post Reply