Contents contain search not working on .torrent files

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hazel version: 5.0.6
macOS version: macOS Mojave 10.14.6

I have searched the forums and have also gone through a few posts here, but am unable to figure this out.

My requirement:
* Move .torrent files (to be clear, these are not the media downloaded using torrents) to specific folders based on the tracker name contained within the file.

What I tried:
* Created one rule with "Contents" "contain" "<tracker domain>"
(here <tracker domain> is the domain name of the tracker which is present within the .torrent file)

Example: File abc.torrent contains (if viewed in quick look or opened in a file viewer) the tracker domain mentioned in the rule, but preview mode (and running the rule too) shows no matches.

This rule does not match for the files in question. I have checked the debug log and have also seen the popup in preview mode (when clicking the red "x" button next to the rule). The popup shows "Not Matched" as the title and below that it shows "Contents" in the first column and nothing in the second column (as if Hazel couldn't read the contents).

Note that .torrent files are not pure text, but do contain readable text (including the tracker URL information). It seems like I'm missing something very obvious. How do I compose the rule for this case?

Thank you.
filewrangler
 
Posts: 2
Joined: Mon May 03, 2021 1:19 pm

Files need to be classified as text by the system. My guess is that torrent files are not. You will need to use a script of some sort to read/parse the contents in this case.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Files need to be classified as text by the system. My guess is that torrent files are not. You will need to use a script of some sort to read/parse the contents in this case.


Thanks for the prompt response. I don't understand what this means: "Files need to be classified as text by the system." I thought it was a reference to the older file type codes and set that as text on a file to test, but that didn't work either.

I'll look at creating a script that can process it and then provide an input to Hazel. Even grep on a terminal is able to find the text in the .torrent file (it shows the string with the --text option, and without that option it just gives a "matches" answer).

Edit: I added a "Passes shell script" option with grep to get the results required.

I have one more question and a potential follow up: is there a specific limitation in how Hazel is coded or designed that it processes only text files? If yes, would it be possible to add changing this aspect to the future roadmap (I'm not expecting anything quick)?

Thanks again.
filewrangler
 
Posts: 2
Joined: Mon May 03, 2021 1:19 pm

Files have types based on their extension. There's a whole "tree" of types where types can descend from more general types, like whether it's a text file, or an image, etc. These are defined by the system and the apps you have on your system that open those files.

Nothing needs to view the contents of torrent files as text so it is not classified as such.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support