On Tuesday, May 22, 2001, at 09:00 PM, Roderick Scott Corporation =
wrote:
> I hope someone can help me. I'm trying to write a handler that will
> crawl a folder path and verify the existence of the path, making new
> folders as necessary to fulfill the path.
As always, keep your appendages in the vehicle at all times and WFLW-
-- Start AppleScript --
set strPath to (((choose folder) as string) &=20
"TestFolder:AnotherTestFolder:YetAnotherOne:") as string
my sureFolder(strPath)
on sureFolder(strPath)
=09
set oldSpaceChar to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
=09
tell application "Finder"
if exists container strPath then
set AppleScript's text item delimiters to =
oldSpaceChar
return true
else
set strFolderPath to ""
repeat with i from 1 to ((count (text items in =
strPath)) - 1)
set strFolderPath to ((text items 1 =
through i of=20
strPath) as string) & ":"
if i =E2=89=A5 2 then set =
strParentFolder to ((text items 1=20
through (i - 1) of strPath) as string) & ":"
set strFolderName to text item i of =
strPath
try
alias strFolderPath
on error
make new folder at =
strParentFolder with=20
properties {name:strFolderName}
end try
end repeat
end if
end tell
set AppleScript's text item delimiters to oldSpaceChar
return true
end sureFolder
-- End AppleScript --
This works given a valid string, and there are better ways to do this. =20=
I prefer to use Akua's when possible -
verify path "Disk:Folder:Folder:Folder:"
Tidy. Lots of other useful stuff in there, too.
Doug Metz
------------------------------
This archive was generated by hypermail 2b29 : Sun May 27 2001 - 12:00:29 AEST