I am trying to make an Applescript that moves a spotlighted file into a folder specified by a dialog. I would like the script to find the path of the folder that I entered, however, I cannot get it to work. Can anyone help? Thanks in advance and bonus points if you can tell me why my code doesn't all go into one block on my preview :( !!
The problem comes where the asterisks begin and end.
Here is the code.
repeat 1 times
set spotlightquery to quoted form of text returned of (display dialog "What do you want to search?" default answer "" buttons {"Search!"} default button 1)
if spotlightquery = "''" then
exit repeat
end if
set thefolders to {path to home folder}
set founditems to {}
repeat with i in thefolders
set thepath to quoted form of POSIX path of i
if exists thepath then
set command to "mdfind -onlyin " & thepath & " " & spotlightquery
set founditems to founditems & (paragraphs of (do shell script command))
end if
end repeat
if founditems = {} then
display dialog "No items found." buttons {"OK"} default button 1
exit repeat
end if
display dialog "" & founditems & "" buttons {"OK"} default button 1
set location to the button returned of (display dialog "Where would you like to move it?" buttons {"C Folder", "Desktop", "Other"} default button 3)
if location = "C Folder" then
tell application "Finder"
set moveTo to "Macintosh HD:Users:aaronmcclellan:Desktop:Coding:C"
move file founditems to folder moveTo
end tell
else
if location = "Desktop" then
tell application "Finder"
set moveTo to the path to desktop folder
move file founditems to folder moveTo
end tell
end if
*if location = "Other" then
set fold to the text returned of (display dialog "Where would you like to move it?" default answer "" buttons {"OK"} default button 1)
set moveTo to fold
tell application "System Events"
##error occurs here
move file founditems to folder moveTo
end tell
end if*
end if
end repeat