Alright, Mr. AppleScript smarty-pants (I grovel before your greatness...) explain this one...
I have a script that takes a URL, parses it down, and attempts to create a folder structure following the URL. Ie, if the URL is
www.apple.com/developer/technotes/TN302.html, it will create a folder named technotes inside a folder named developer inside a folder named
www.apple.com. (The idea being that then it would download TN302.html into that bottom folder.)
Unfortunately, the script is only able to create the top level one, then it fails with a useless error message of 'Finder error, could not make folder'. Gee, thanks for the info.
However, if I take the text from the event log window, and paste it into a new Script Editor window and run it, it can create the new secondary level folder just fine.
(Yes, I realize that some browsers (IE) have support for sucking down a whole website... I don't want that. I need specific control over what's downloaded when/where, and this seems like a trivial little problem that I can't seem to solve.)
Here's the code, more or less:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
on run
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {<font color = red>"/"</font>}
set browserURL to <font color = red>""</font>
tell application <font color = red>"OmniWeb"</font>
set browserURL to (address of front browser) as text
end tell
display dialog browserURL
set dirList to words of browserURL
-- Chop off http:
set dirList to items <font color = blue>2</font> thru (length of dirList) of dirList
set baseDir to <font color = red>"Mac OS X:Users:<usernamegoeshere>

ocuments:"</font>
set dlDir to baseDir
tell application <font color = red>"Finder"</font>
repeat with folderName in dirList
set dlDirFull to dlDir & folderName & <font color = red>":"</font>
display dialog <font color = red>"Checking: "</font> & dlDirFull
if (not (folder dlDirFull exists)) then
display dialog <font color = red>"Making new folder "</font> & folderName & <font color = red>" at: "</font> & dlDir
make new folder at dlDir with properties {name:folderName}
end if
set dlDir to dlDirFull
end repeat
end tell
set AppleScript's text item delimiters to savedDelimiters
end run
</font>[/code]
[ 10-23-2001: Message edited by: Kickaha ]