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
if you have an HFS path, convert it to Posix like this:
set HFS_Path POSIX to file "MacIntosh HD/Users/jean/"
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: