Check the existence of a file on any computer - file path question

Can you use “~/” while checking?

I’ve currently got:

if the file "The Cave:Users:chrisowen:Library:Application Support:Camino:user.js" exists then

I need to remove “The Cave:Users:chrisowen” so my script can be used on any computer. What can I put there instead?

I thought “~:Library:Application Support:Camino:user.js” but it doesn’t… :confused: Help!

“~” is a *nix thing; Check out the path to command in StandardAdditions.

path to home folder
(path to application support folder from user domain as Unicode text) & "Camino:user.js"

Choose “Open Dictionary.” from Script Editor’s File menu, and then find StandardAdditions in the list.

By default, path to returns an alias. If you want to add something to the path, then return it as Unicode text, concatenate your own stuff, and if needed, coerce it back to an alias or file.

set caminoUserJS to ((path to application support folder from user domain as Unicode text) & "Camino:user.js") as file specification

tell application "Finder"
	-- whatever
	
	if caminoUserJS exists then
		-- whatever
	end if
	
	-- whatever
end tell

Awesome! Thanks Bruce Phillips. My script is done now and I’m heading right over to Code Exchange. :smiley: