The syntax for search in Metadata Lib is:
set theFolder to choose folder
set theMetadata to perform search in folders {theFolder} predicate string "kMDItemFSName ENDSWITH[c] '.txt'"
and the definition of “in folders” is:
A list of files, aliases, POSIX paths or NSURLs of folders to search in.
If I run this script, everything is fine:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Metadata Lib"
set MyDoi to "10.1038/ng.1009"
set theFolders to {alias "MacBook HD:Users:ldicroce:Desktop:for_ERC:Single Cell:"}
set {a1, a2, b1, b2, c2} to {"kMDItemDescription", MyDoi, "kMDItemFinderComment", MyDoi, ".pdf"}
set theMetadata to perform search in folders {theFolders} predicate string "(%K CONTAINS[c] %@ OR %K CONTAINS[c] %@) AND kMDItemFSName ENDSWITH[c] %@" search arguments {a1, a2, b1, b2, c2}
But this one, triggers an error
set MyDoi to "10.1038/ng.1009"
set theFolders to {alias "MacBook HD:Users:ldicroce:Desktop:for_ERC:Single Cell:", alias "MacBook HD:Users:ldicroce:Desktop:for_ERC:To_sort:"}
set {a1, a2, b1, b2, c2} to {"kMDItemDescription", MyDoi, "kMDItemFinderComment", MyDoi, ".pdf"}
set theMetadata to perform search in folders {theFolders} predicate string "(%K CONTAINS[c] %@ OR %K CONTAINS[c] %@) AND kMDItemFSName ENDSWITH[c] %@" search arguments {a1, a2, b1, b2, c2}
The error is:
Can’t get POSIX path of {alias “MacBook HD:Users:ldicroce:Desktop:for_ERC:Single Cell:”, alias “MacBook HD:Users:ldicroce:Desktop:for_ERC:To_sort:”}.
Any suggestion on what I am doing wrong?
(I also tried with posix paths or files. Same error.
Thanks
L.