File does not exist but AS thinks so?

Sorry to keep asking file path questions, but I’m trying to keep my head screwed on straight. I’m trying to run a series of scripts testing that I make file paths correctly (to ingrain it in myself). This one I am having the voice tell me if a file already exists in this location: /Users/vtaccess/Pando/packages/
The file is test.mp3 and NO it does not exist yet! But the voice keeps telling me it does…so do I have the paths wrong again? Because when the voice says the path it sounds right to me…


set myFile to "test.mp3"

set pandoPackage to quoted form of ((path to home folder as Unicode text) & "Pando:packages:" & myFile & ".pando")
if (exists pandoPackage) then
	say (pandoPackage as string) & space & "already exists"
end if

Hi,

first: quoted form is only necessary for shell scripts and actually only, if there could be space characters in the path

Same problem as before. Only the Finder (and System Events) can check the presence of a file or folder with exists

set myFile to "test.mp3"

set pandoPackage to ((path to home folder as Unicode text) & "Pando:packages:" & myFile & ".pando")
tell application "Finder"
	if (exists file pandoPackage) then
		say (pandoPackage as string) & space & "already exists"
	end if
end tell

but there is also a way without the Finder: Coercing a path to an alias throws an error, if the file (or folder) doesn’t exist

set myFile to "test.mp3"

set pandoPackage to ((path to home folder as Unicode text) & "Pando:packages:" & myFile & ".pando")
try
	pandoPackage as alias
	say (pandoPackage as string) & space & "already exists"
on error
	-- do something
end try

You’re checking if a string exists (they always do):

set myFile to "test.mp3"

set pandoPackage to quoted form of ((path to home folder as Unicode text) & "Pando:packages:" & myFile & ".pando")
class of result
--> Unicode text

Also, why are you using quoted form for this?

See also: I can never get the exists command to work properly…

AHHG. I don’t know why, but this is the most confusing part of applescript to me (I should probably say thus far). Thanks again for setting me straight.