• 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
Re: Creating folders (directories) without the Finder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating folders (directories) without the Finder


  • Subject: Re: Creating folders (directories) without the Finder
  • From: "Arthur J Knapp" <email@hidden>
  • Date: Fri, 23 Mar 2001 11:41:21 -0500

> Subject: Re: Re: Creating folders (directories) without the Finder
> From: email@hidden
> Date: Thu, 22 Mar 2001 00:41:17 EST

> My question applied to a piece of a piece of my ever evolving shopping cart
> CGI suite, cartHandle.

I just went and looked this up. Very cool! :)

It is a great example of an advanced and sophisticated AppleScript
project, good stuff.

> ... What I really needed was a way to verify that a folder
> existed and create its full path if it did not. I had a venerable but
> occasionally unpredictable plain vanilla handler trio that has performed that
> task for me

I found your trio, and decided to create my own implementation. Here is
what I came up with:

Note: Replace backslash, "\", with option-L.


-- Example: call f_ifNotFolder( "MacHD:folderA:folderB" ) to create
-- folder(s) folderA and/or folderB if they do not exist.

on f_exists(pathString)
try
alias pathString

return true
on error
return false
end try
end f_exists

on f_makeFolder(parentPathString, folderName)

tell application "Finder" to \
make new folder at folder parentPathString \
with properties {name:folderName}

end f_makeFolder

on f_ifNotFolder(pathString)

if f_exists(pathString) then return

set {oldDelim, AppleScript's text item delimiters} to \
{AppleScript's text item delimiters, {":"}}

try
set pathString to text items of pathString

repeat with x from 2 to length of pathString

if not f_exists((items 1 thru x of pathString) as string) then

f_makeFolder((items 1 thru (x - 1) of pathString) as string, \
item x of pathString)

end if
end repeat

on error errorMessage number errorNumber
set text item delimiters to oldDelim
error errorMessage number errorNumber

end try
set text item delimiters to oldDelim

end f_ifNotFolder


Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://home.earthlink.net/~eagrant/


  • Prev by Date: Re: QuarkXPress: finding anchored boxes
  • Next by Date: Watched folder in OS X 10.0
  • Previous by thread: Re: Creating folders (directories) without the Finder
  • Next by thread: Re: Creating folders (directories) without the Finder
  • Index(es):
    • Date
    • Thread