安妮給你一個很好的劇本,但是我的身影,你可以讓這對自己非常容易。我假設商店總是與一個地區和網站相關聯,因此您可以將這些信息輸入到腳本中,然後您可以從列表中選擇它,而不是每次都輸入。
因此,您需要創建一個包含該信息的記錄列表。我在腳本頂部的storeRegionRecord中爲您輸入了4個樣本。您還需要在需要下載文件的變量下載文件夾中輸入文件夾路徑。
下面是按照說明輸入信息後腳本的工作方式。彈出一個對話框,您可以選擇一個或多個商店/地區/網站組合進行下載。如果一個日期適用於其中幾個,你會選擇多於一個。按住Shift鍵或按住Command鍵在對話框中選擇多於1個。然後彈出第二個對話框,輸入特定日期。重複循環遍歷您選擇的商店/地區/網站,並將每個pdf文件下載到下載文件夾中,並按照Anne的代碼中的建議命名下載的pdf。
我希望這有助於...
property storeRegionRecord : {{store:"store1", region:"region1", website:"http://store1.website.com/"}, {store:"store2", region:"region2", website:"http://store2.website.com/"}, {store:"store3", region:"region3", website:"http://store3.website.com/"}, {store:"store4", region:"region4", website:"http://store4.website.com/"}}
property aDate : ""
property listDelimiter : "*"
set downloadFolder to path to desktop as text
-- get the store/region/website to download. You can choose more than 1.
set chooseList to chooseListForStoreRegionRecord(storeRegionRecord)
choose from list chooseList with title "PDF Downloads" with prompt "Choose one or more..." default items (item 1 of chooseList) OK button name "Select" cancel button name "Quit" with multiple selections allowed
tell result
if it is false then error number -128 -- cancel
set selectedItems to items
end tell
-- enter the date
display dialog "Date?" default answer aDate
set aDate to the text returned of the result
-- download the files
set text item delimiters to listDelimiter
repeat with aSelection in selectedItems
set theVariables to text items of aSelection
set theStore to item 1 of theVariables
set theRegion to item 2 of theVariables
set theWeb to item 3 of theVariables
if theWeb does not end with "/" then set theWeb to theWeb & "/"
set link to theWeb & theStore & "/" & theRegion & "/" & aDate & "NL/" & theStore & "_" & theRegion & "_" & aDate & "NL.pdf"
set destination to downloadFolder & theStore & "_" & theRegion & "_" & aDate & "NL.pdf"
tell application "URL Access Scripting" to download link to file destination replacing yes
end repeat
set text item delimiters to ""
-- tell me that it's finished
display dialog "The PDF files were downloaded to:" & return & (downloadFolder as text) buttons {"OK"} default button 1 with icon note
(*============= SUBROUTINES ===============*)
on chooseListForStoreRegionRecord(storeRegionRecord)
set chooseList to {}
repeat with aRecord in storeRegionRecord
set end of chooseList to store of aRecord & listDelimiter & region of aRecord & listDelimiter & website of aRecord
end repeat
return chooseList
end chooseListForStoreRegionRecord