Энн дала вам хороший сценарий, но я полагаю, вы можете сделать это очень легко для себя.Я предполагаю, что магазин всегда связан с регионом и веб-сайтом, поэтому вы можете ввести эту информацию в скрипт, а затем просто выбрать ее из списка, а не вводить ее каждый раз.
КакТаким образом, вам нужно создать список записей с этой информацией.Я ввел для вас 4 образца в storeRegionRecord в верхней части скрипта.Вам также необходимо ввести путь к папке в переменной downloadFolder , куда следует загружать файлы.
Вот как работает скрипт после ввода информации, как объяснено.Появится диалоговое окно, в котором вы можете выбрать одну или несколько комбинаций магазина / региона / веб-сайта для загрузки.Вы бы выбрали более 1, если дата будет применяться к нескольким из них.Удерживая клавишу «Shift» или «Command», выберите более 1 в диалоговом окне.Затем появляется второй диалог, в котором вы вводите конкретную дату.Повторяющийся цикл циклически перебирает выбранный вами магазин / регион / веб-сайты и загружает каждый файл PDF в папку загрузки, называя загруженный файл 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