Preserve the original file name in a text file

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
akacharos
Posts: 1
Joined: 30 Jan 2022, 12:18

Preserve the original file name in a text file

Post by akacharos »

Hi,

I am trying to figure out what seems fairly simple to do, yet I need some direction . I want to run filebot upon torrent completion in qbittorrent (Run an external program on torrent completion) and generate a text file (eg. release.txt) with the filenames of the torrent along with the media info of the video and place that file in the torrent folder.
My idea is to preserve the release name before renaming the files/folder (as a way to keep track the downloaded release in case of future video substitution or future subtitle downloading).

System environment is Ubuntu and using cli (no gui)

Any ideas?
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: help with file info export with cli

Post by rednoah »

:idea: FileBot will store the original file name to xattr by default, so you can always retrieve the original file name from there later. Please read Metadata and Extended Attributes for details. Note that although xattr work reliably on local file systems, all bets are off once remote SMB file systems are in the mix.


:idea: Alternatively, you can also query the history for the original file path of a previously processed file.


:idea: If you are set on writing your own custom text files, then you can do that via the -exec option and a custom shell script:
rednoah wrote: 14 Sep 2019, 19:43 e.g. call a custom script and pass along file paths and metadata:

Code: Select all

-exec /path/to/script.sh {f} {historic.f} {json}
You can use -find -exec to generate your release.txt files after the fact. Also, good for testing your custom script. If you're using the amc script though then it's best to do it at the time, but FileBot can do it later too if needed, as long as you have xattr or history.
:idea: Please read the FAQ and How to Request Help.
brijazz
Posts: 25
Joined: 25 May 2022, 20:53

Re: Preserve the original file name in a text file

Post by brijazz »

Any suggestions on how to go about putting the original filename into the Finder's 'Comments' field on a Mac?
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Preserve the original file name in a text file

Post by rednoah »

brijazz wrote: 28 Aug 2023, 11:42 Any suggestions on how to go about putting the original filename into the Finder's 'Comments' field on a Mac?
How does one set the Comments field on a Mac? Is it a Mac Finder xattr attribute? Is it an embedded media property? Is there a way to set the Comments field in Finder, or ideally via a command?



EDIT:

Looks like macOS uses the com.apple.metadata:kMDItemFinderComment xattr attribute so that makes things easy:
https://eclecticlight.co/2020/11/06/fin ... -avoiding/



EDIT 2:

Setting the com.apple.metadata:kMDItemFinderComment xattr attribute unfortunately does not seem to do the trick:
https://discussions.apple.com/thread/250638567

:idea: You could try something like this, since there does not seem to appear a standard tool for setting Finder comments, so osascript might be the only option:

Shell: Select all

filebot -find /input --filter f.video -exec \
osascript -e 'tell app "Finder" to set comment of (POSIX file "{f}" as alias) to "{original}"'


EDIT 3:

It's a good example use case for the new custom post-processing scripts feature.

Screenshot
:idea: Please read the FAQ and How to Request Help.
Post Reply