Concoct string to to make valid path

I’m trying to concoct a folder path with a file name to make a valid path but it isn’t working, though the path looks just a like the path to the file in the terminal. Why doesn’t the following work?


set imageToOpen to theDirectory & imageName as Unicode text
tell application "Finder"
		set theImage to quoted form of POSIX file imageToOpen
end tell

Basically I’m getting path to theDirectory by (choose Folder) method, and then I’m typing in a existing file
name at that path. I’ve tried several different methods (quoted form of POSIX path, alias) and combinations
of those with no success.

Any help appreciated.

Hi,

the question is, what kind of path do you want?

You get a HFS path (colon separated) with


set theDirectory to choose folder
set theHFSpath to (theDirectory as text) & "file.ext"

You get a POSIX path (slash separated) with


set theDirectory to choose folder
set thePOSIXpath to (POSIX path of theDirectory) & "file.ext"

thanks for the quick response Stefan, that got rid of the error and the path still looks right, but Photoshop won’t open either. Hm. Just when I think I understand file paths… :confused:

I’m testing this on a file on my desktop, but eventually it’ll lead to a path on an NT server, so I’ll
be using the posix form.


set a to (choose folder)
set imageName to "thefile.psd"

set imageToOpen to (a as text) & imageName
	
	tell application "Adobe Photoshop CS4"
		activate
		open imageToOpen
	end tell

You need to coerce the string to an alias or put in a file designator for photoshop to open it:

set a to (choose folder)
set imageName to "keep_calm_boutique_main.jpg"

set imageToOpen to (a as text) & imageName

tell application "Adobe Photoshop CS3"
	activate
	open alias imageToOpen
end tell

or

set a to (choose folder)
set imageName to "keep_calm_boutique_main.jpg"

set imageToOpen to (a as text) & imageName

tell application "Adobe Photoshop CS3"
	activate
	open file imageToOpen
end tell