デスクトップにファイルを書き込もうとしていますが、ファイルが見つからないというエラーがスローされます。ファイルがなくてもエラーが表示される場合は、コードにファイルを作成するように依頼しました。以下は私のコードです。
tell application "Finder"
try
set myFile to ("TestReport.txt")
set logpath to (((path to desktop from user domain) as string)) as alias
set logfile to myFile
tell application "Finder" to make new file at (logpath) with properties {name:myFile}
on error --file exist yet, so create it
set logfile to myFile as alias
display alert logfile
end try
try
tell application "Finder" to make new file at ((path to desktop from user domain) as string) with properties {name:"TestReport.txt"}
set logmsg to "File Rename"
--set logmsg to (numberoflines as string) & ") " & tab & mylogin & tab & curDate & tab & thecount & tab & "Ver.1" & return
set the logdata to (open for access file (logfile as text) with write permission)
write logmsg to the logdata starting at eof
close access logdata
return true
end try
end tell
ご意見をお聞かせください。ありがとう。