Re: Making Folders
Re: Making Folders
- Subject: Re: Making Folders
- From: Mark Lively <email@hidden>
- Date: Fri, 6 Jan 2006 11:01:51 -0500
On 1/6/06, Steve Suranie <email@hidden> wrote:
> Hi all:
>
> I am trying to write a subroutine that creates folders based on user input.
> I'm getting a syntax error when I go to check if the name the user selected
> already exists. The error I am getting states:
>
> Expected "," but found identifier
>
> Here's the subroutine:
>
> on folderMaker(topLevelPath, i)
> display dialog "Item" & i & ": Enter the name of the folder you are
> creating. Please use the format SKU_DESCRIPTION_MODALITY" default answer
> "EXAMPLE: 00001_RedShirt_HI"
> set thisFolderName to text returned of result as string
> set folderPath to topLevelPath & thisFolderName
> (*THIS IS WHERE THE SCRIPT IS BREAKING> ON THE IF STATEMENT BELOW*)
> if not (exists folder thisFolderName of (topLevelPath as alias)) then
> display dialog "Make folder"
> else
> display dialog "This folder already exists, would you like to select
> another name?" buttons {"Yes", "No"} default button "No"
> end if
> end folderMaker
>
> I've copied this bit of script from another script on the Apple web site:
>
> on adding folder items to this_folder after receiving these_items
> tell application "Finder"
> if not (exists folder "Done" of this_folder) then
> make new folder at this_folder with properties {name:"Done"}
> end if...
>
> I can get it to compile if I rewrite it as:
>
> if not (exists thisFolderName of (topLevelPath as alias)) then
>
> but then I get an error message saying
>
> Can't get thisFolderName of alias "ImageDump:Online
> _Shop_Originals:2006:HI:HI_apparel:tops:".
>
> Any help would be appreciated
>
> Thanks
>
> Steve
A few things
1) exists file BobLoblaw must be inside a Finder tell block and that
tell blcok must be inside the subroutine.
2) alias toplevelpath fails if toplevelpath doesn't exist.
3) What you have that compiles is trying to find a string which is an
element of an alias. Since aliases aren't objects they don't have
elements.
4) try this
tell application "Finder"
if not exists folder thisFolderName of folder topLevelPath then
display dialog "No love."
else
display dialog "Whoop there it is."
end if
end tell
-Mark
Off to find a tweedle beetle battle paddle.
_______________________________________________
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