Reputation: 1827
I am using this syntax in my Applescript but I am getting an error file not found. I am sure the file is there. Is there anything wrong with this?
set rtfFile to "Macintosh HD:Users:ash:Documents:Core:_Marketing:xlsafe_p.rtf" as alias
Upvotes: 0
Views: 344
Reputation: 2282
Here is a little handler to check at which point of your path the error occurs:
set rtfFile to "Macintosh HD:Users:ash:Documents:Core:_Marketing:xlsafe_p.rtf"
checkPath(rtfFile)
on checkPath(aPathToCheck)
set oldATID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set pathElements to text items of aPathToCheck
set AppleScript's text item delimiters to oldATID
set d to ""
set tempPath to ""
repeat with i from 1 to (count pathElements)
set tempPath to tempPath & d & item i of pathElements
try
set foo to tempPath as alias
on error
display alert "The path " & return & tempPath & return & "is not valid!" buttons {"OK"}
return false
end try
set d to ":"
end repeat
display alert "The path " & return & tempPath & return & "is valid!" buttons {"Yeah!"}
return true
end checkPath
Here it says The path Macintosh HD:Users:ash is not valid! because I'm logged in with other credentials than you ;-) Please try this handler and tell us the result!
Enjoy, Michael / Hamburg
Upvotes: 1
Reputation: 1409
Try to choose the file with this, copy the text from the alert, and compare the result.
display alert ((choose file) as text)
Upvotes: 0