–Can i search a mounted volume to find a file whose comment contains “some text”
tell application “Finder”
set search_source to disk “graphics”
set find_this to “some text”
set thefile to every file of search_source whose name or comment contains find_this
end tell
compiles but:
thx in advance for any help with this
set thefile to {}
tell application "Finder"
set search_source to disk "graphics"
set find_dialog to display dialog "Find What" default answer ""
set find_this to the text returned of the result
set thefile to every file of search_source whose name contains find_this
if thefile is {} then
set thefile to every file of search_source whose comment contains find_this
end if
end tell
any suggestions would be great
Just to explain the original problem, the issue was with the line:
set thefile to every file of search_source whose name or comment contains find_this
In a comparison statement like this, the ‘or’ separates conditions, therefore this statement is thought of as:
set thefile to every file of search_source whose (name) or (comment contains find_this)
Clearly, (name) isn’t a valid comparison.
If the original line had been written as:
set thefile to every file of search_source whose name contains find_this or comment contains find_this
you’d have been OK since it decodes as:
set thefile to every file of search_source whose (name contains find_this) or (comment contains find_this)
Thanks Andrew. That works, and thanks for the explanation too. ;¬)
Hi 
So, if you want to look in the totality of the volume, you can use an instruction with “entire contents”, for exemple:
set thefile to every file of entire contents of ¬
search_source whose (name contains find_this) or (comment contains find_this)

thanks to all for your input
revision
i have just noticed that the script only looks at the root level and not in subfolders
what would be the easiest way to force it to look into subfolders?
set thefile to {}
tell application "Finder"
set search_source to disk "graphics"
set find_dialog to display dialog "Find What" default answer ""
set find_this to the text returned of the result
set thefile to every file of search_source whose name contains find_this
set thefile to every file of search_source whose name contains find_this or comment contains find_this
(*
if thefile is {} then
set thefile to every file of search_source whose comment contains find_this
end if
*)
end tell