I am trying to make a folder to go on a server, that people can add photos to and then the script sends them to the correct place, however I'm having trouble with the search part.
As you can see below in my code, the part where it finds where to send the folder to is commented out, because I have no idea what the syntax is for it.
Any help would be greatly appreciated.
global theWatchedFolder
set theWatchedFolder to choose folder
on idle
tell application "Finder"
set theDetectedItems to every item of theWatchedFolder
repeat with aDetectedItem in theDetectedItems
set jobNumber to display dialog "Please enter the job number for this photo." buttons {"Submit", "Cancel"}
display dialog "File detected: " & jobNumber
--tell finder
-- search for jobNumber in (path to desktop)
--set jobFolder to top search result
--end tell
--set colourFolder to jobfolder & /colour
move aDetectedItem to the desktop --move to colourFolder
end repeat
end tell
if theDetectedItems is not {} then
activate
display dialog "test move complete"
end if
return 1
end idle
Also, I am concerned that if this script is on the server, watching a folder on the server, then it won't create a pop-up for anyone who adds a file to the folder on the server. Hopefully I am wrong but if someone could confirm this one way or the other then that would be awesome. Thanks 🙂
Best Answer
For local files/folders
you can use spotlight's command line tools. In Terminal
will give you all folders whose name starts with
xyz
with the search begining from your home folder~/
. Remove*
inxyz*
above to find an exact match. For more information onmdfind
read the man page using the commandman mdfind
in Terminal app.You can use it in your script like this...
For remote files
that spotlight doesn't know about, you can use the good old UNIX
find
command.You can use it in your script the same way as
mdfind
but it may be a bit slower.Hope that helped.