-- uses Script Tools Suite Mark Alldritt (InfoMac) Regular Expressions -- uses Script Tools Suite Mark Alldritt (InfoMac) File I/O -- -- (C) Hado Hein , 1999, Berlin, Fed Rep of Germany -- Background : You want to suck some hierachical trees of an webserver. -- With luck the server gives you an directory. This Page you save in your browser to disk. -- In this file are HREFS of all files in that directory. -- In my case there were >1K files in some directories. -- I tried downloading with "WebDevil" (info-Mac). I got some files then the connection dropped. -- The Situation was that I had dragged and dropped all directory-html-files into one big html which contained now all 1700 fileHREFs -- Some of them were already downloaded in a copied directory structure on my disk. -- how to parse a new file that only held the HREFs that had to be downloaded ? -- This script does. Taking line by line from Input file, looking if the file exits and if writing it out to the new download file -- probably you need to knit your own Reg Expr. to match the HREFS. -- The Output File can be used to download with WebDevil again. on parseLine(aLine, outfile, matchfolder, regex) tell application "Finder" set regrep to match regular expression regex to aLine if (machine of regrep) then set fileway to match 2 of regrep set filename to match 4 of regrep set askfile to ((matchfolder as text) & fileway & ":" & filename) if not (exists file askfile) then write file outfile text aLine end if end if end tell end parseLine on run tell application "Finder" try set infileStr to choose file with prompt "Suck List ist where ?" -- that is a file that holds HREFS of files that shall be downloaded -- Suck File MUST have Macintosh Linebreaks. set matchfolder to choose folder with prompt "Root folder of here Files ?" -- that is the folder structure on a local volume where some files might be if (exists file ((startup disk as text) & "Desktop Folder:db2outie.html")) then set outfile to open file ((startup disk as text) & "Desktop Folder:db2outie.html") for writing lengthen file outfile length 0 else create file "db2outie.html" in ((startup disk as text) & "Desktop Folder:") owner "R*ch" set outfile to open file ((startup disk as text) & "Desktop Folder:db2outie.html") for writing end if set infile to open file infileStr for reading set regex to compile regular expression "(/DB2/)([^/]*)([/]*)([^\">]*)" --"(\\\">)([^]*)([^<]+)" -- this gives as result 2 the path and 4file , let's see if this one exists here repeat while ((get file position infile) æ (get file length infile)) set filePos to get file position infile set tempStr to read file infile maximum length 512 parseLine(tempStr, outfile, matchfolder, regex) of me end repeat close file infile close file outfile on error close file infile close file outfile end try end tell end run