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)
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:
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
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.