• 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: New Folder if it doesn't exist
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Folder if it doesn't exist


  • Subject: Re: New Folder if it doesn't exist
  • From: Joseph Weaks <email@hidden>
  • Date: Wed, 12 May 2004 00:49:12 -0500

On May 11, 2004, at 10:09 PM, Dustin Bell wrote:
I would like to write a script that will create a folder on my desktop if the folder doesn't exist. How would I go about writing that, as I know that in apple script you must be perferct for it to work.

set folderName to "MyFolder"
set folderPath to
tell application "Finder" to if not (exists folder ( (path to desktop as string) & "MyFolder") then make new folder at (path to desktop folder) with properties {name:folderName}



If you didn't need to invoke the Finder, the best way to check for a file is to try and make its path into an alias, and catch the error.

try
alias folderPath
on error
-- Doesn't exist, so do your stuff
end try

Cheers,
Joe Weaks
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >New Folder if it doesn't exist (From: "Dustin Bell" <email@hidden>)

  • Prev by Date: Re: New Folder if it doesn't exist
  • Next by Date: Re: New Folder if it doesn't exist -- Ignore
  • Previous by thread: Re: New Folder if it doesn't exist
  • Next by thread: Re: New Folder if it doesn't exist -- Ignore
  • Index(es):
    • Date
    • Thread