• 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
Use of 'path to ... folder creation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Use of 'path to ... folder creation


  • Subject: Use of 'path to ... folder creation
  • From: Dennis Jones <email@hidden>
  • Date: Fri, 6 May 2005 12:55:14 -0700

Can someone give me an example of how to specify a folder to use and
create the folder if it does not exist.

My script uses ~/my-home/tmp to store a temporary file. I need the
script to create the tmp folder if it does not exist. From reading the
'path to' dictionary entry, it looks to me as if it could take care of
this for me.

--code snippit--
on printResults(searchString, wordList)
	set homeFolder to path to home folder as string
	set tmpFolder to (((homeFolder) as string) & "tmp:") as string
                  -- would like to create folder 'tmp' if it does not exist.
	set lpFile to (tmpFolder & "lp.txt") as string
	set fileRef to open for access file lpFile with write permission
	write ("Result of search for: " & searchString & return & return &
wordList) as string to fileRef
	close access fileRef
	display dialog "Printing" buttons {"OK"} default button 1
	do shell script "lp ~/tmp/lp.txt"
	do shell script "rm ~/tmp/lp.txt"
end printResults

-- dictionary entry --
path to: Returns full path name to the folder or application specified
	path to  application support/applications folder/desktop/desktop
pictures folder/documents folder/favorites folder/Folder Action
scripts/fonts/frontmost application/help/home folder/internet
plugins/keychain folder/library folder/modem scripts/movies folder/...
 -- the folder or application to return
		[from  system domain/local domain/network domain/user domain/Classic
domain]  -- where to look for the indicated folder
		[as  type class]  -- the type to return: alias or string (default is alias)
		[folder creation  boolean]  -- Create the folder if it doesn't
exist? (default is true)
	Result:   alias  -- the path name to the folder or application specified


--
Dennis Jones
email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Use of 'path to ... folder creation
      • From: "Gary (Lists)" <email@hidden>
    • Re: Use of 'path to ... folder creation
      • From: Alastair Rankine <email@hidden>
    • Re: Use of 'path to ... folder creation
      • From: kai <email@hidden>
  • Prev by Date: Re: Script as internet helper protocol in tiger
  • Next by Date: Re: How to use the "Find" command in Tiger Finder?
  • Previous by thread: Re: Illustrator save as PDF; adding extra bleed?
  • Next by thread: Re: Use of 'path to ... folder creation
  • Index(es):
    • Date
    • Thread