
I'm using hazel to write "tags" to spotlight comments based on the name of a file. Then this file is sorted into different subfolders based on creation date ( YYYY -> MM).
The problem is I would like to use a software like YEP, because I don't wan't to have so many different "custom searches" in the finder to find bills from a single company or a special date. So I needed a way to write these "tags" from the filename also to the openmeta tags. At the moment Hazel doesn't support custom fields in openmeta tags. (http://www.noodlesoft.com/forums/viewtopic.php?f=4&t=1847) So I couldn't set tags dynamically from the filename.
So I tried my first steps with applescript and here is the result:
- Code: Select all
set openmeta to "/Applications/openmeta/openmeta"
tell application "Finder"
set theFilename to (name of theFile) as string
set theFilePath to (the POSIX path of theFile)
set thisfile to (POSIX file theFilePath) as alias
set theFileComment to the comment of thisfile
end tell
set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {","}}
set myList to text items of theFileComment
set AppleScript's text item delimiters to myTID
repeat with myItem in myList
set theTags to do shell script openmeta & " -a " & myItem & " -p " & quoted form of POSIX path of theFile
end repeat
return {hazelExportTokens:{filename:theFilename, comment:theFileComment}}
I think the code isn't perfect and maybe it could be much shorter, but at the moment it works. Could someone with some more applescript Knowledge please take a look at it and tell me if something isn't done as it should?
Thanks so much
Jamest