• 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: Duplicate with replacing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Duplicate with replacing


  • Subject: Re: Duplicate with replacing
  • From: Michelle Steiner <email@hidden>
  • Date: Thu, 10 Feb 2005 00:34:56 -0700

On Feb 10, 2005, at 12:27 AM, Bernard Azancot wrote:

set folderLocation to path to desktop as text --using desktop for sake of example.
set folderName to "test folder"
tell application "Finder"
if not (exists folder (folderLocation & folderName)) then
make new folder at folder folderLocation with properties {name:folderName}
end if
end tell


Great !
That works perfectly... but, don't you think AS's behavior is a little user unfriendly in that case ?

No, not really. You can't do something with or to something that doesn't exist. So, first you check to see if it exists, and if it doesn't, you create it.


Another way to handle this situation is to use an on error handler; try to duplicate to a folder, and if the target folder doesn't exist, trap the error and create the folder, then duplicate. I think that checking first is easier, though.

Of course, because the if-then is only one statement, it could be done in one line, without "end if"

Thanks a lot for the lesson, Michelle.

De nada.

-- Michelle

--
I am Dyslexic of Borg. Fusistance is retile. Your ass will be laminated.

_______________________________________________
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


References: 
 >Duplicate with replacing (From: Bernard Azancot <email@hidden>)
 >Re: Duplicate with replacing (From: Michelle Steiner <email@hidden>)
 >Re: Duplicate with replacing (From: Bernard Azancot <email@hidden>)
 >Re: Duplicate with replacing (From: Michelle Steiner <email@hidden>)
 >Re: Duplicate with replacing (From: Bernard Azancot <email@hidden>)
 >Re: Duplicate with replacing (From: Michelle Steiner <email@hidden>)
 >Re: Duplicate with replacing (From: Bernard Azancot <email@hidden>)
 >Re: Duplicate with replacing (From: Michelle Steiner <email@hidden>)
 >Re: Duplicate with replacing (From: Bernard Azancot <email@hidden>)

  • Prev by Date: Re: Duplicate with replacing
  • Next by Date: Re: styled text from script editor to fmp
  • Previous by thread: Re: Duplicate with replacing
  • Next by thread: Re: Duplicate with replacing
  • Index(es):
    • Date
    • Thread