Finder "Open" issue

Hello,

I have created the following script:

set theCC to "CC199"
tell application "System Events"
	set theUser to the name of the current user
end tell
tell application "Finder"
	activate
	set theFolder to theUser & ":Clients:" & theCC & ":"
	open theFolder
end tell

Which produces an “does not exist error”

So I set another script to get me the right path name

tell application "Finder"
	set theUser to (choose folder)
end tell

Which reveals that the path is right in form. Problem must be the class. Sure enough, the first script produced a result that is a text. The second produces a class of alias. Sure I could just make an alias with the right path but this is used by various users on different networks so the path changes by the user name. Also the target folder changes based on the client file being used in FileMaker. So, how do I get a script to open the folder for the client that exists in “Clients” in the user name folder?

Thanks
Marcus

Model: MacBook
AppleScript: 2.3
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)

Hi,

the Finder needs the full path to the folder, starting with a disk.
There is a home property to get ta reference to the current user


set theCC to "CC199"

tell application "Finder"
	set theFolder to (home as text) & "Clients:" & theCC & ":"
	open folder theFolder
end tell

Hi, MSpsi.

The path in your first script begins with the user folder name, which is wrong in an HFS path. It should begin with the disk name. (I see Stefan’s beaten me to the post with this. :))

Two (other) possible approaches are:

  1. A command called path to, one of whose possible parameter values is home folder.
set theCC to "CC199"
set theUser to (path to home folder as text)

tell application "Finder"
	activate
	set theFolder to theUser & "Clients:" & theCC & ":"
	open folder theFolder
end tell
  1. The Finder’s own home keyword.
set theCC to "CC199"

tell application "Finder"
	activate
	set theFolder to "Clients:" & theCC & ":"
	open folder theFolder of home
end tell

Stefan and I have inserted the keyword folder into the open line because ideally, an appropriate item specifier should be used. (The idea is to open a folder, not a piece of text.) But in fact the Finder’s one of the applications which nowadays (sometimes) let you get away with just a path.

Thanks both. It worked wonderfully!