• 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: Basic script blues ;-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic script blues ;-)


  • Subject: Re: Basic script blues ;-)
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 27 Mar 2005 10:05:26 -0800

On 3/27/05 9:45 AM, "Bernard Azancot" <email@hidden> wrote:

> Just a little question.
>
> Two versions of the same basic script.
> Both compile.
> The first one is OK (a folder is created, when not existing).
> The second not.
> I cannot find what is the problem with the 2nd one...
>
> -- 1st script: OK --
>
> try
> tell application "Finder"
> if not (exists folder "IBM 01:Users:parents:Desktop:Foo:Folder2") then
> make new folder at folder "IBM 01:Users:parents:Desktop:Foo:" with
> properties {name:"Folder2"}
> end if
> end tell
> end try
>
> -- end of 1st script--
>
>
>
> -- 2nd script: wrong --
>
> try
> tell application "Finder"
> set Folder1 to folder ("IBM 01:Users:parents:Desktop:Foo")
> if not (exists folder (Folder1 & ":Folder2")) then
> make new folder at folder Folder1 with properties {name:"Folder2"}
> end if
> end tell
> end try
>
> -- end of 2nd script--
>
> Thanks in advance for your help.

You set Folder1 variable to be a folder, not a string. Within a Finder tell
block, that will resolve to a Finder object (folder "Foo" of folder
"Desktop" of... etc.) Then you tried to concatenate that thing to a string
beginning with a colon ("Folder2"). That's obviously not going to work. Just
set your variable to a string to begin with:

    tell application "Finder"
        set Folder1 to "IBM 01:Users:parents:Desktop:Foo"
        if not (exists folder (Folder1 & ":Folder2")) then
            make new folder at folder Folder1 with properties
{name:"Folder2"}
        end if
    end tell


Although not required, you might have seen it more clearly if you'd included
the colon at the end of the folder paths:

    tell application "Finder"
        set Folder1Path to "IBM 01:Users:parents:Desktop:Foo:")
        if not (exists folder (Folder1Path  & "Folder2:")) then
            make new folder at folder Folder1 with properties
{name:"Folder2"}
        end if
    end tell


--
Paul Berkowitz


 _______________________________________________
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: 
 >Basic script blues ;-) (From: Bernard Azancot <email@hidden>)

  • Prev by Date: Basic script blues ;-)
  • Next by Date: Re: Basic script blues ;-)
  • Previous by thread: Basic script blues ;-)
  • Next by thread: Re: Basic script blues ;-)
  • Index(es):
    • Date
    • Thread