• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Tell Finder Make New Folder wierdness!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tell Finder Make New Folder wierdness!


  • Subject: Tell Finder Make New Folder wierdness!
  • From: Roderick Scott Corporation <email@hidden>
  • Date: Tue, 22 May 2001 16:21:53 -0600

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. Unfortunately, once my
script passes the point of creating a folder, it can no longer use
that new folder to place anything into it i.e. another folder. I
simply get an error that the last folder I created does not exist -
and therefore I cannot make a new folder in it.

Here is my code so far. Note I return a True, but have not finished
adding any error trapping:

>on sureFolder(strPath)
>
> -- save & modify the text item delimeter to ":" for path manipulation
> set oldSpaceChar to AppleScript's text item delimiters
> set AppleScript's text item delimiters to ":"
>
> -- direct commands to the Finder
> tell application "Finder"
>
> activate
>
> -- test to see if the entire path is valid
> if folder strPath exists then
> -- restore the text item delimeter
> set AppleScript's text item delimiters to oldSpaceChar
>
> return true
>
> else -- proceede to building the path
> -- initialize a variable to hold the
> set strFolderPath to ""
>
> -- loop through the path, verifying the existence of each level
> -- Note:We don't want the last field after the final : as it
>will always be empty and hence the count -1 limit
> repeat with i from 1 to ((count (text items in strPath)) - 1)
>
> -- extract the sub-path from left to right, adding the final
>path colon
> set strFolderPath to ((text items 1 through i of strPath) as
>string) & ":"
>
> -- get the name of the folder
> set strFolderName to text item i of strPath
>
> -- verify existence of this sub-path and build it if it does not exist
> if not (folder strFolderPath exists) then
>
> -- do the deed, make the folder within the last valid folder
> make new folder at strParentFolder with properties
>{name:strFolderName}
>
> end if
>
> -- capture the last folder to place next folder into
> set strParentFolder to strFolderPath as alias
>
> end repeat
> end if
>
> end tell
>
> -- re-activate the script application
> activate
>
> -- restore the text item delimeter
> set AppleScript's text item delimiters to oldSpaceChar
>
> return true
>
>end sureFolder

Thanks in advance for any assistance,

Scott
________________________________________
Scott Sandeman-Allen
Roderick Scott Corporation
Edmonton, Alberta. Canada


  • Prev by Date: Re: counting w*rds
  • Next by Date: Re: Scope of globals, parents and children
  • Previous by thread: Re: Installer Observer Substitute, or an applescript workaround
  • Next by thread: Re: Tell Finder Make New Folder wierdness!
  • Index(es):
    • Date
    • Thread