-- drag-and-drop interface: on open fileList repeat with aFile in fileList processFile(aFile) end repeat say "Finished downloading files." end open -- double-click interface: on run set aFile to choose file with prompt "Select a file of URLs to download:" processFile(aFile) say "Finished downloading files." end run -- process one file of URLs on processFile(pFile) -- read the file set fileRef to (open for access pFile without write permission) set headerFile to (read fileRef as text using delimiters return) close access fileRef -- process each line as a URL to download repeat with aLine in headerFile processURL(aLine) end repeat end processFile -- download one URL, and save in a folder on processURL(pURL) -- we need to get the filename from the end of the URL set oldDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to "/" set fname to last text item of pURL set AppleScript's text item delimiters to oldDelim -- wait until Netscape isn't busy waitTillIdle() -- get the file from the network tell application "Netscape Navigatorª 2.0" activate GetURL pURL to file ((path to desktop as string) & fname) end tell say "Downloading " & fname end processURL -- wait until Netscape isn't downloading something on waitTillIdle() repeat until isIdle() end repeat end waitTillIdle -- is Netscape currently downloading something? on isIdle() -- loop through all windows; if a download window (i.e. not resizable), return false; -- if a hypertext window (i.e. resizable) and it's busy, return false tell application "Netscape Navigatorª 2.0" repeat with i from 1 to 99 -- is there such a window at all? try set garbage to name of window i -- fails if window i doesn't exist on error return true -- no more windows, and none were busy end try if not (resizable of window i) or  (busy of window i > 0) then return false end repeat end tell end isIdle