使用以下代码示例来修复If-Else语句错误,使得Apple Script可以找回1年前的笔记。
tell application "Notes"
set deletedNotes to every note whose modification date is less than ((current date) - (365 * days))
repeat with eachNote in deletedNotes
set noteText to (body of eachNote as text)
set noteTitle to (name of eachNote as text)
if noteText contains "DELETE" then
delete eachNote
else
set creationDate to (creation date of eachNote)
make new note at folder "Notes" with properties {name:noteTitle, body:noteText}
set (modification date of result) to creationDate
delete eachNote
end if
end repeat
end tell
这个代码示例可以遍历Notes中的已删除笔记,找到最近一年内修改过的笔记并将其找回。如果找到笔记的标题或正文中包含"DELETE",则直接删除该笔记;否则,新建一个笔记并将其属性设置为找到的已删除笔记的标题、正文和创建日期,然后再将找到的已删除笔记删除。使用这个代码可以修复原有的If-Else语句错误,并实现笔记找回的功能。