【发布时间】:2022-01-11 03:05:23
【问题描述】:
我正在使用 Automator 应用程序(拖放)来重命名一些文件。我想做的一件事是去掉 zip 文件的“从哪里来”。此脚本有效,除了它在运行时询问文件,而允许我将文件拖放到应用程序图标的顶部。
我做错了什么?如何使应用程序可拖放?
on deleteWhereFrom(fileToClean)
try
set posixPath to quoted form of POSIX path of fileToClean
do shell script "xattr -d com.apple.metadata:kMDItemWhereFroms " & posixPath
end try
end deleteWhereFrom
on open zip
repeat with i in zip
deleteWhereFrom(i)
end repeat
end open
on run
set zip to choose file with multiple selections allowed
repeat with i in zip
deleteWhereFrom(i)
end repeat
end run
【问题讨论】:
-
你不需要 Automator,只需要一个 AppleScript script 保存为 application .看看:Processing Dropped Files and Folders
-
谢谢。但是,我实际上在该 Automator 脚本中有一串其他命令(重命名、替换等)。剥离“从哪里来”只是我需要做的一部分。当它到达那一点时,它会要求文件而不是从我已经在应用程序上删除的文件中删除“从哪里来”。也许我误解了你的建议?
-
Automator 应用程序是获取被删除项目的工具,因此请使用 AppleScript 操作的输入参数(文件项目列表)而不是打开处理程序(或
choose file命令)。跨度> -
好的,谢谢。我现在有了。我可以手动抓取文件并且它可以工作。我希望有一种方法可以将它们拖到应用程序图标上并让它工作。
-
文件可以拖到 AppleScript 或 Automator 应用程序上。
标签: applescript automator