Search for text string within file

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

Moderator: Mr_Noodle

Search for text string within file Tue Oct 03, 2023 6:27 am • by khardman
Hi Hazel community.

I'm a newbie and excited to utilize this much-touted tool.

I am trying to do something which should be simple.

USE CASE
Search a single directory of plain text markdown files for the phrase "publish: true". Move a copy of each file containing this phrase to another directory.

My rule:

If all of the following are met:

Contents....contain match...."publish: true"

Do the following:

Copy to folder TEST


Unfortunately, no files are moving. Any thoughts?

Thank you in advance.

Kevin
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Tue Oct 03, 2023 8:46 am • by Mr_Noodle
I believe you emailed in to support with the same issue. In the future, please use only one channel or the other.

As I already suggested in email, going through the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for text string within file Tue Oct 03, 2023 9:18 am • by khardman
Thank you, Mister Noodle :)

Eager new user.

Peace.
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Tue Oct 03, 2023 9:27 am • by khardman
Rule status said there's no match.

Here's the log:

2023-10-03 08:20:53.340 hazelworker[3457] Running worker (v5.2.2) for folder with identifier: 16777233-14428976.
2023-10-03 08:20:53.342 hazelworker[3457] ###Arch: arm64
2023-10-03 08:20:53.342 hazelworker[3457] ###main load address: 0x1042c0000
2023-10-03 08:20:53.342 hazelworker[3457] ###Hazel Core load address: 0x1048d4000
2023-10-03 08:20:53.342 hazelworker[3457] ###Noodle load address: 0x104bcc000
2023-10-03 08:20:53.342 hazelworker[3457] ###CK load address: 0x1047c8000
2023-10-03 08:20:53.370 hazelworker[3457] Processing folder Obsidian
2023-10-03 08:20:55.454 hazelworker[3457] Done processing folder Obsidian
2023-10-03 08:22:29.639 hazelworker[3472] Running worker (v5.2.2) for folder with identifier: 16777233-14428976.
2023-10-03 08:22:29.641 hazelworker[3472] ###Arch: arm64
2023-10-03 08:22:29.641 hazelworker[3472] ###main load address: 0x10251c000
2023-10-03 08:22:29.641 hazelworker[3472] ###Hazel Core load address: 0x102b30000
2023-10-03 08:22:29.641 hazelworker[3472] ###Noodle load address: 0x102e28000
2023-10-03 08:22:29.641 hazelworker[3472] ###CK load address: 0x102a24000
2023-10-03 08:22:29.665 hazelworker[3472] Processing folder Obsidian
2023-10-03 08:22:31.803 hazelworker[3472] File type not supported: {(
"public.folder",
"public.directory",
"public.item"
)}
2023-10-03 08:22:31.804 hazelworker[3472] Done processing folder Obsidian


The folder I want to scan is on iCloud. Can Hazel scan iCloud folders?
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Tue Oct 03, 2023 11:15 am • by khardman
I am continuing to experiment after reading other posts. I have made sure Hazel has Full Disk access. I have also confirmed Hazel has access to iCloud under File & Folders.

Still no luck.

I then moved the folder out to iCloud to test. No luck. Here's the log:

2023-10-03 10:11:14.103 hazelworker[1254] Done processing folder kevinOS
2023-10-03 10:11:43.796 hazelworker[1258] Running worker (v5.2.2) for folder with identifier: 16777233-21338867.
2023-10-03 10:11:43.799 hazelworker[1258] ###Arch: arm64
2023-10-03 10:11:43.799 hazelworker[1258] ###main load address: 0x104d18000
2023-10-03 10:11:43.799 hazelworker[1258] ###Hazel Core load address: 0x10532c000
2023-10-03 10:11:43.799 hazelworker[1258] ###Noodle load address: 0x105624000
2023-10-03 10:11:43.799 hazelworker[1258] ###CK load address: 0x105220000
2023-10-03 10:11:43.815 hazelworker[1258] Processing folder kevinOS (forced)
2023-10-03 10:11:45.948 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.951 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.954 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.956 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.958 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.960 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.962 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.965 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.967 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.969 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.971 hazelworker[1258] File type not supported: {(
"public.item",
"public.folder",
"public.directory"
)}
2023-10-03 10:11:45.972 hazelworker[1258] Done processing folder kevinOS
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Wed Oct 04, 2023 8:34 am • by Mr_Noodle
In the rule preview, click on the red X to see what the text looks like to Hazel.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for text string within file Wed Oct 04, 2023 9:54 am • by khardman
Pardon my ignorance, I do not know how to post the image of my screenshot. When I trigger "Preview Rule":

    -Red X "Rule does not match"
    -When I click the second Red X next to the attribute, it says "Not Matched" on the first line. The second line only says "Contents" with no other information.

Thanks for helping me resolve this.
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Thu Oct 05, 2023 9:20 am • by Mr_Noodle
So the contents are not readable by Hazel. Do you have any apps installed that handle markdown files?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for text string within file Thu Oct 05, 2023 11:24 am • by khardman
Mr_Noodle wrote:So the contents are not readable by Hazel. Do you have any apps installed that handle markdown files?


I am using Obsidian. Is there a way for Hazel to read the markdown file?
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Fri Oct 06, 2023 9:33 am • by Mr_Noodle
Can you run the 'mdls' command on the file and post the output?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for text string within file Fri Oct 06, 2023 5:18 pm • by khardman
I'm a neophyte so I don't know how to do that. I understand the mdls command will extract the metadata. Sorry for holding my hand here.
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Mon Oct 09, 2023 9:45 am • by Mr_Noodle
- Launch Terminal
- Type mdls
- Press space
- Drag the file in question into the Terminal window and drop.
- Hit return.
- Send me the output
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for text string within file Mon Oct 09, 2023 11:37 am • by khardman
Here's the output:

(null): no filename specified!

usage: mdls [-s][-attr attr][-sdb] [-raw [-nullMarker markerString]] [-plist file] path
list the values of one or all the attributes of the specified file
-attr -n : fetch specific attribute
-raw -r : don't print attribute names before values
-nullMarker -m : substitute this string for null attributes in raw mode
-plist -p : output attributes in XML format to file. Use - to write to stdout
option -plist is incompatible with options -raw, -nullMarker, and -attr
-sdb -s : implies -attr _kMDItemSDBInfoexample: mdls ~/Pictures/Birthday.jpg
example: mdls -attr Keyword ~/Pictures/Birthday.jpg

khardman@Kevins-MacBook-Air ~ % mdls /Users/khardman/Library/Mobile\ Documents/iCloud\~md\~obsidian/Documents/kevinOS/TKWA\ Dashboard/Projects/Amy\ Mietzel\ Residence.md
kMDItemFSContentChangeDate = 2023-10-04 19:39:10 +0000
kMDItemFSCreationDate = 2023-10-04 18:35:13 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "Amy Mietzel Residence.md"
kMDItemFSNodeCount = 204
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 204
kMDItemFSTypeCode = ""
khardman@Kevins-MacBook-Air ~ % mdls /Users/khardman/Library/Mobile\ Documents/iCloud\~md\~obsidian/Documents/kevinOS/TKWA\ Dashboard/Projects/Friedman\ Alley.md
kMDItemFSContentChangeDate = 2023-09-26 15:27:33 +0000
kMDItemFSCreationDate = 2023-09-19 20:52:19 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "Friedman Alley.md"
kMDItemFSNodeCount = 261
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 261
kMDItemFSTypeCode = ""

And here's the text contained within the Markdown file:

---
publish: true
filetype:
- archproject
pipeline:
- TKWA Active
---
# Project Details
Location: [[Waukesha, Wisconsin]]
Owner/Developer: [[City of Waukesha]]
Architect: [[The Kubala Washatko Architects]]
General Contractor:
People:
[[Robin Grams]]

# News

I am trying to move files within the directory that contain the text "publish: true".

Thank you!
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Re: Search for text string within file Mon Oct 09, 2023 12:26 pm • by awaldraff
khardman wrote:
Mr_Noodle wrote:So the contents are not readable by Hazel. Do you have any apps installed that handle markdown files?


I am using Obsidian. Is there a way for Hazel to read the markdown file?


I also use obsidian and I can confirm that hazel reads the markdown files perfectly.
awaldraff
 
Posts: 32
Joined: Fri Sep 23, 2016 3:47 pm

Re: Search for text string within file Mon Oct 09, 2023 1:37 pm • by khardman
What attribute are you using to search the Markdown files?

I am trying to search for a specific text string. I am using Contents | contains match | text value
khardman
 
Posts: 17
Joined: Mon Oct 02, 2023 9:44 pm

Next

Return to Support