First attempt at scripting the finder

Hi all,

I’m in the middle of writing a small utility appliation for my office, and I’m writing the first bit of script I’ve ever scripted that interacts with the Finder. As I’ve been doing the whole way through building the app, I tested a small piece of code in Script Editor, that worked perfectly …

tell application "Finder"
	if folder ("Macintosh HD:Users:Peter:Desktop:" & "TestFolder") exists then
		delete folder "Macintosh HD:Users:Peter:Desktop:TestFolder"
	end if
	set FirstFolder to make new folder at "Macintosh HD:Users:Peter:Desktop:" with properties {name:"TestFolder"}
end tell

… but when I cut and paste that very same code into Applescript Studio, I get a syntax error whenever I try to save or run the app. It’s usually along the lines of "Expected “then”, etc. but found “(”. depending on how I try and tweak the code.

Is there someting I haven’t spotted that could be wrong? And why would a bit of Script Editor code not work in Applescript Studio?

Thanks for all your help.

Peter :slight_smile:

Model: Mac mini G4
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

What handler are you pasting it into?

You know what, I should really hang my head in shame, and let you know that I just spotted the issue. When I pasted the code, I only pasted the middle segment, re-typing the “tell” and “end tell” statements. Guess who forgot to put “” around the word Finder… Me.

Incidentally, it was a sub-routine I was writing that was called from an on object clicked handler. Thanks Bruce.

Peter :slight_smile: