I am using a series of text files containing a word per line and reading those text files into an AppleScript to check if the file name that Hazel passed to it contains any of the words in the text file.
I am doing it this way because I am using those same text files across multiple rules to filter files that can pass the general criteria phase but are sorted differently if they do or do not contain a sub-criteria or a combination. It helps me keep track of it rather than having the same matching criteria populated in multiple rules and if I forget to update one a file is missed.
As I update the text files all the rules become more refined.
What I don't understand is that the exact script below works for another script file and the only difference is which text file it is referencing. All of these were working nicely and sorting hundreds of files and all of a sudden kind of stopped. I ran a move all to monitored folder action and tried running them through again and only a few files actually end up sorted where they should.
- Code: Select all
on hazelMatchFile(theFile, inputAttributes)
-- set fileName to first item of inputAttributes list
set fileName to item 1 of inputAttributes
-- set path to matchFile:
set matchFile to paragraphs of (read alias "Users:XXXX:XXXX:#Hazel:Library:Genre:EXAMPLE.txt")
-- iterate through the matchList, textstring by textstring:
repeat with textString in matchFile
if textString is in fileName then
return true
else
return false
end if
end repeat
end hazelMatchFile