Sure. I guess personally I'd step out to the shell and do the find there. Let's say I want to search my documents folder for a file named "prop.png", then the command in Terminal would be:
Code:
find ~/Documents -type f -name "prop.png"
That will search all folders recursively, which can be a pain in AppleScript. If you want to limit how many folders deep you want to search then you can do:
Code:
find ~/Documents -type f -name "prop.png" -maxdepth 5
...adjust the '5' according to how many folders deep you want to search.
To roll that into an AppleScript you could use something like:
Code:
--I've hard coded the file name.
set theFiles to every paragraph of (do shell script "find ~/Documents -type f -name \"prop.png\" -maxdepth 1")
--display an error if no files were found
if (count of theFiles) is 0 then
display alert "Error" message "No files found"
return
end if
--I'm assuming that only the one file will be found. If there are several, we just deal with the first match
set theFile to (POSIX file (item 1 of theFiles))
tell application "Finder"
activate
reveal theFile
end tell
I've not tested this thoroughly and it's not production ready code - it's just intended to be good enough to get you going.
Hope that's of some help!