Hello All I have been trying to get a script for a scenario where i need to setdownload path to a mounted Volume and then access a url from Safari. I got bits a pieces of code from the forums but i seem to be getting a error.
set downloadsFolder to quoted form of POSIX path of “HELLO:”
Thank you so much one other query though. I see the url getting navigated and file downloaded but file Doesnt get downloaded to the path.
The Path that I set is the a external mounted Volume
I’m not sure that you can set that (outside of Safari’s preferences). When I run defaults read com.apple.Safari, nothing like that is listed. I’m running Sierra so it’s very possible that apple has added and removed some of the defaults.
However, if your version does have such a default to change, then typically it doesn’t happen instantly. You might have to restart safari or kill its process first. I’m not sure when Safari reads its defaults.
Absent that, you might be able to just move the file there once it’s downloaded.
set url_item to {"https://www.learningcontainer.com/download/sample-text-file/?wpdmdl=1669&refresh=63b94aeb182c416730877"}
tell application "Finder"
set df to (path to downloads folder)
set fdfBef to files of df as alias list
end tell
tell application "Safari"
set xy to make new tab at window 1 with properties {URL:url_item}
end tell
tell application "Finder"
delay 4
set fdfAft to files of df as alias list
repeat with x in fdfAft
if x is not in fdfBef then
set label index of x to 4
-- or…
move x to desktop
end if
end repeat
end tell
Of course, if you add other files to the downloads folder by other means, they would get caught up in this too.