如何使用AppleScript在桌面上创建一个文件夹并将拖放的文件移动到其中?
我想做一个Applescript。我想在其上放置一个文件(.app 文件),并且它应该在与放置的文件相同的目录中创建一个名为“Payload”的文件夹。比它应该复制拖放到 Payload 文件夹中的文件。 Payload 文件夹现在应该被压缩。扩展名应从 .zip 更改为 .ipa。现在,.ipa 文件应重命名为拖放文件的文件名。最后,它应该删除创建的文件夹(如果还没有),并且删除的项目也应该被删除。
我该怎么做?
非常感谢。
没明白吗?请发表评论。 :)
I want to make an Applescript. I want to drop a file on it (.app file) and than it should create a folder named "Payload" in the same directory as file that was dropped. Than it should copy the file that was dropped to the Payload folder. The Payload folder should now be zipped. Than the extension should be changed from .zip to .ipa. And the .ipa file should now be renamed to the file name that the droppped file has. And at the end it should delete the folder that was created (if not already) and the dropped item should be deleted too.
How can I do this?
Thank you very much.
Didn't understand it? Please drop a comment. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,我假设您正在使用
告诉应用程序“Finder”
步骤编写 Finder 脚本。如果是这种情况,请查看 Finder 字典中的move
命令来移动文件,并查看delete
来删除文件。关于压缩,当我需要使用AppleScript压缩文件时,我发现使用带有
do shell script
的shall命令和zip命令行工具(输入man zip 在终端窗口中或查看 在线手册页)。
如果您不熟悉
move
、delete
和do shell script
,请查看 Finder 的 AppleScript 字典(对于move< /code> 和
delete
以及标准脚本添加(用于do shell 脚本
)。First of all, I'm assuming that you're scripting the Finder with a
tell application "Finder"
step. If that's the case, check out themove
command in the Finder's dictionary to move the file, anddelete
for removing the file.Regarding zipping, when I've needed to compress a file with AppleScript, I've found that using a shall command with
do shell script
and the zip command line tool (typeman zip
in a Terminal window or take a look at the online man page).If you're unfamiliar with
move
,delete
anddo shell script
, check out the AppleScript dictionary for the Finder (formove
anddelete
and the Standard Scripting Addition (fordo shell script
).结合查克的回答,您可以使用 文件夹操作来完成此操作...
In conjunction with Chuck's answer, you could use Folder Actions to accomplish this...
您可以使用“文件夹”操作作为答案来完成此操作
。首先,创建文件夹。
Puis,编写此 AppleScript
说明,将文件夹操作添加到文件夹:
观看文件夹说明
或者在 Automator 中,您可以使用此代码添加 AppleScript,您只需从 automator 设置一个变量并将其返回到AppleScript,用于您放入 targetFolder 中的文件夹。
这就是我目前找到的全部内容。
此致
You can do that with a Folder action as the anwser up
First, create your folder.
Puis, write this AppleScript
Instructions for adding a folder action to a folder:
Watching Folders Instructions
Or In Automator you can add an AppleScript with this code, you just need to set a variable, from automator and return it to AppleScript, for the folder you dropped in the targetFolder.
This is all I found for now.
Best regards