This simple handler can detect if a path is valid without asking System Events or the Finder. It is also faster.
on ExistsThisPath(thePath)
try
alias thePath
return true
on error
return false
end try
end ExistsThisPath
--> works for folders
set theFolder to (choose folder) as string
--> I chose "Macintosh HD:Users:jean:Documents:"
set AreUthere to ExistsThisPath(theFolder) --> true
set AreUthere to ExistsThisPath("Macintosh HD:Users:jean:Docs:") -->false
--> works for files
set theFile to (choose file) as string
--> I chose "Macintosh HD:Users:jean:Documents:Expresso.pdf"
set AreUthere to ExistsThisPath(theFile) --> true
set PosixPath to "/Users/jean/Documents/Expresso.pdf"
ExistsThisPath(POSIX file PosixPath) --> true
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: