– this works searching a file on my laptop
set Search_Folder to “Macintosh HD:Users:shawn:Desktop:Test”
set Search_Folder2 to POSIX path of Search_Folder --Macintosh HD/Users/shawn/Desktop/Test
set search_word to “zzasdasd”
set x to (do shell script “find " & Search_Folder2 & " -name zzasdasd*”)
– Test folder has 5 subfolders, each folder has 40 files, shell script find, finds the file in blink of an eye
– this does not work, accessing a server at work
set search_word to text returned of result & "" as string – campy
set Search_Folder to “10.10.x.x:AudioNAS:Ah2”
set Search_Folder2 to POSIX path of Search_Folder – /10.10.x.x/AudioNAS/Ah2
set x to (do shell script "find " & Search_Folder2 & " -name " & search_word)
– here is the error I get:
– error “Finder got an error: find: /10.10.x.x/AudioNAS/Ah2/: No such file or directory” number 1
not working, I get the spinning gear and “running” at the bottom of the editor window. after 30 seconds I get “” as the result. Dang.
tell application “Finder”
set Search_Folder to "/Volumes/AudioNAS/Ah2"
set search_word to "*campy*"
set x to (do shell script "find " & quoted form of Search_Folder & " -name " & search_word)
this is not working. It gets hung up on getting the quoted form:
tell application “Finder”
set search_word to “Campy”
repeat with a_folder in folder "AudioNAS:Ah2:Comedy:"
repeat with a_sub_folder in folder in a_folder
set x to (do shell script "find " & quoted form of a_sub_folder & " -name " & search_word) as string
end repeat
end repeat
You can’t get the quoted form of a Finder reference, only of text.
I’m not clear if your server volume is “10.10.xx” or "AudioNAS. If it’s the former, you probably need:
set Search_Folder to "/Volumes/10.10.xx/AudioNAS/Ah2"
set search_word to "*campy*"
set x to (do shell script "find " & quoted form of Search_Folder & " -name " & quoted form of search_word)
You don’t need to invoke the Finder for ‘do shell script’.
‘find’ is recursive and will search every subfolder of the search folder, so you don’t need a repeat.
Since you’ve been a MacScripter member for over thirteen years, do you think you could learn to use our [applescript] and [applescript] tags when posting code?
Yeah that’s fine. The tags are just for AppleScript code which people may want to look at in their script editors. Clicking the “Open this Scriplet in your Editor:” link above the posted code opens the code in their default editors automatically, although there are a couple of security checks to OK during the process nowadays.
So we’re still trying to find the correct POSIX path to the folder on your server.
Since the folder’s on a disk other than your startup disk, the path must begin with “/Volumes”, as above. Then there should be another slash, followed by the name of the server mount point as it appears on your desktop. Then more slashes and names reflecting the path down through the folder hierarchy from the mount point to the folder you want to search. The path in my script supposes a mounted volume called “10.10.xx” on your desktop, which contains a folder called “AudioNAS” and, in that, a folder called “Ah2”, which the script searches for items whose names contain “campy” in lower-case letters. The names in the path too must agree in case with those on the server. The script will only work while the server volume’s mounted.
The server 10.10.x.x is visible in the sidebar under shared.
The Main folder AudioNAS is visible in a Finder window
so far so good
The error shows a “:” after the path. A “:” should not be in the path
should be /volumes/shares/folder/folder/
can’t figure out how to get rid of the “:” campy does need to be Campy to match the file name.
this works but takes a while to pop up the results. Like 1 minute. I was hoping for 5 seconds.
set Search_Folder to "/Volumes/AudioNAS/AH2"
set search_word to "* Campy *"
set x to (do shell script "find " & quoted form of Search_Folder & " -name " & quoted form of search_word)
I don’t know. I’m getting pretty instantaneous results quizzing a large folder on another Mac in the same room at home over a wi-fi connection. But there could be all sorts of things to slow down communication with an office server, such as distance, how many other computers it’s having to serve, what else it’s doing in the background, the fact that “find”'s searching another machine’s drive, etc. There may not be anything that can be done to speed it up, scriptwise.