Yes, there are several ways that you can access this kind of custom data. But first, you need to know the
actual name of the custom property.
To do this, open terminal, and run
mdls on the file:
- Code: Select all
mdls /path/to/my/file.pdf
Scan the result for what you're interested in, and make a note of the name of the property. Odds are, it will have a prefix like
kMDItemCustomProperty.
Matching based on known custom propertiesIf you want to MATCH based on a property's value, you can do this:
- Code: Select all
if [ "$(mdls -name kMDItemName "$1" | awk -F " = " '{print $2}')" == "THE VALUE THAT YOU ARE INTERESTED IN MATCHING" ];then exit 0; else exit 1; fi
And place this embedded script within an "passes shell script" condition. Your rule will match every file whose custom property is what you're interested in finding.
Using custom properties as tokensYou can use this applescript and applescript hazel tokens to extract custom field information.
- Code: Select all
set posixPath to quoted form of (POSIX path of theFile) as string
set theCustomToken to (do shell script "/usr/bin/mdls -name kMDItemName " & posixPath & " | awk -F ' = ' '{print $2}'")
return {hazelExportTokens:{theCustomTokenValue:theCustomToken}}
Then you can use the token however you'd like!