• 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: Ultra Newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ultra Newbie question


  • Subject: Re: Ultra Newbie question
  • From: Bill White <email@hidden>
  • Date: Mon, 01 Dec 2003 17:13:15 -0500

> I want to modify the script so that it will perform the intended
> functions on ANYONE'S desktop but am having a difficult time figuring out a
> correct "set path" statement that will allow the script to create the folder
> in the CURRENT USER'S Desktop folder on anyone's machine. Any ideas?
>
> tell application "Finder"
> activate
> make new folder at folder "Desktop" of folder "larry" of folder "Users"
> of startup disk with properties {name:"untitled folder"}
> set name of folder "untitled folder" of folder "Desktop" of folder
> "larry" of folder "Users" of startup disk to "My Amazing New Folder"
> end tell

Larry,

You just need "path to desktop" to get the path to the current user's
desktop folder. You can also set the name of the folder at the same time
it's created, as follows:

set desktopPath to path to desktop

tell application "Finder"
make new folder at desktopPath with properties {name:"My Amazing New
Folder"}
end tell

Note that "activate" isn't needed; the Finder will do the work in the
background for you.

You might want to put things in a "try block" to catch an error if the
folder already exists.

set desktopPath to path to desktop

tell application "Finder"

try
make new folder at desktopPath with properties {name:"My Amazing New
Folder"}
end try

end tell

Hope that helps,

Bill
_______________________________________________
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: 
 >Ultra Newbie question (From: Lawrence Conley <email@hidden>)

  • Prev by Date: Re: Ultra Newbie question
  • Next by Date: Re: Telling remote computer to "do shell script"
  • Previous by thread: Re: Ultra Newbie question
  • Next by thread: Re: Ultra Newbie question
  • Index(es):
    • Date
    • Thread