Maipol
2023-04-18 11:21:59 +08:00
tell application "Finder"
-- 获取当前选中文件列表
set finderSelectionList to selection as alias list
-- 判断是否有选中的文件
if length of finderSelectionList = 0 then
-- 如果没有,就弹出提示
display alert "== Alert ==" message "请选中一个文件或者文件夹!" as critical
else
-- 如果有,就获取第一个文件
set theFile to (item 1 of finderSelectionList)
-- 获取文件的注释
set oldComment to comment of theFile
-- 获取文件的名称
set theFileName to name of theFile
-- 生成对话框的信息
set theMsg to "输入注释"
-- 弹出对话框
set theResponse to display dialog theMsg default answer oldComment with icon note with title "Finder" buttons {"Cancel", "Continue"} default button "Continue"
-- 设置新的注释
set comment of theFile to (text returned of theResponse)
end if
end tell