2011-09-02 67 views
3

喜歡的東西:如何使用AppleScript下載文件?

set the file_tgt to (path to downloads as string) as file specification 
    set file_src to "http://my_file.png" 
    tell application "URL Access Scripting" 
     download file_src to file_tgt 
    end tell 
  1. 我如何獲取路徑,爲用戶的默認下載文件夾?
  2. AppleScript不喜歡路徑轉換。我該如何解決這個問題?

回答

0

下載使用AppleScript和shell腳本目錄中的宿主文件的集合 -

set counter to 0 
repeat 36 times 
    do shell script "curl -f 'http://stage.omatics.com/Images/Devices/Devices/" & counter & ".png' -o ~/Desktop/" & counter & ".png" 
    set counter to counter + 10 
    delay 2 
end repeat 

這將下載這36個文件

http://stage.omatics.com/Images/Devices/Devices/0.png 
http://stage.omatics.com/Images/Devices/Devices/10.png 
http://stage.omatics.com/Images/Devices/Devices/20.png 
-- 
-- 
http://stage.omatics.com/Images/Devices/Devices/350.png 

在您的桌面上。

希望這會有所幫助。