标签: automator

Automator脚本,用于在Mac OS X上重命名文件

有没有一种简单的方法在OS X上使用Automator来替换带有下划线的文件名中的空格?

automator

5
推荐指数
1
解决办法
2万
查看次数

通过 AppleScript 发送带有附件的电子邮件

所以我希望能够使用 applescript 发送带有附件的电子邮件。我有一位老师经常让我们做实验并要求我们通过电子邮件发送它们,所以我决定结合榛子和 Applescript 来使这更容易。

基本上,当我将文档导出到文件夹中的 pdf 时,榛子会检测到它并将其发送到另一个文件夹,然后该文件夹调用发送带有附件的电子邮件所需的脚本。完成后,淡褐色将文件放回原始文件夹中,并在名称后附加一个 _sent 以便它不会再次发送。(除非文件刚刚导出为 pdf,否则该文件夹始终为空)

我的问题是这些文件没有附加到电子邮件中。(大多数时候我的脚本会出错,说它没有成功运行,但这不是重点)。

我在使用 automator 时遇到了同样的问题,没有附加文件。我尝试了几个代码,但总是遇到同样的问题。发送的电子邮件不附带任何文件。这是代码:

tell application "Finder"
set folderPath to folder "Macintosh HD:Users:user_directory:Desktop:Send_Mail"
set fileList to name of file 1 in folderPath
end tell

set theSubject to fileList
set theBody to "Hello sir. Here is my " & fileList
set theAddress to "Some Email"
set theAttachment to fileList
set theSender to "Some Sender"

tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:theSubject,         content:theBody & return …
Run Code Online (Sandbox Code Playgroud)

email applescript attachment automator

5
推荐指数
1
解决办法
2万
查看次数

检查与Applescript/Automator的有效互联网连接

我有一个Automator工作流来ping服务器,并下载我经常使用的计划的最新副本.然后将此计划复制到我的保管箱,以便我可以在手机上查看.在工作流程下载最新计划之前,它会从dropbox中删除旧计划.

除非我没有活动的互联网连接,否则这种方法很有效.当我没有活动的互联网连接时,工作流程仍然会打开Dropbox,删除旧计划,并尝试下载最新的计划.因为没有连接,所以不会下载任何内容.然后,如果我的连接变为活动状态,则空的保管箱将同步,并且计划将从我的手机中删除.

我正在尝试添加几行AppleScript代码来ping服务器以查看我是否有活动连接.如果我不这样做,那么等待大约5秒钟再次ping.我希望有5次ping尝试,此时如果我仍然没有活动连接,那么我想完全退出.

我对applecript很新,所以我对如何处理来自命令的错误感兴趣,在这种情况下,ping.如果命令"ping -o www.apple.com"失败,请等待5秒钟并重试ping.如果5次尝试失败,则完全退出.

applescript action automator

5
推荐指数
2
解决办法
8740
查看次数

在NSUserAutomatorTask中设置变量

我正在将一些代码从AMWorkflow迁移到NSUserAutomatorTask,这样我最终可以沙箱化我的应用程序.我希望能够在AMWorkflow中设置工作流中现有变量的值,其中:

AMWorkflow *task = [[AMWorkflow alloc] initWithContentsOfURL:scriptURL error:nil];
[task setValue:@"myValue" forVariableWithName:@"myVar"];
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法使用NSUserAutomatorTask获得类似的功能.我能找到的唯一文档(类引用)表示将变量作为NSDictionary提供.

所以我正在尝试这样的事情:

NSUserAutomatorTask * task = [[NSUserAutomatorTask alloc] initWithURL:workflow error:nil];

task.variables = [NSDictionary dictionaryWithObject:@"myValue" forKey:@"myVar"];
[task executeWithInput:nil completionHandler:^(id result, NSError *error){
    if(error)
        NSLog(@"Error while executing workflow %@", [error localizedDescription]);
}];
Run Code Online (Sandbox Code Playgroud)

我在另一个答案(使用带有沙盒应用程序的AMWorkflow)中读到,忽略了NSUserAutomatorTask的"executeWithInput:"提供的值.变量是否也可能?

macos objective-c automator

5
推荐指数
1
解决办法
218
查看次数

如何将 shell 脚本输出传递给通知?

我想exiftool -k -P -overwrite_original_in_place -ImageDescription= "$1"/*.ARW在通知中显示 shell 脚本运行 ( ) 的结果。我试图$1在主题中用作文本,但它显示的是 $1 而不是脚本输出。

macos shell notifications automator

5
推荐指数
2
解决办法
2818
查看次数

如何在 Applescript 中调用 Automator 变量?

在此处输入图片说明

所以我有一个显示对话框的 Applescript,然后自动机将变量设置为条目

例子 。. . 输入“AAAAAAA”查询变量将是“AAAAAAA”

我正在尝试找出一种在运行我的下一个 applescript 时调用变量的方法

我知道如何通过使用 sys.argv 1和 stdin -> 参数来使用 Python shell 脚本

我怎样才能用 Applescript 实现这一点?

我看到了一个类似的帖子标题,但答案没有解决这个问题

variables macos applescript arguments automator

5
推荐指数
1
解决办法
1万
查看次数

如何在Xcode中为自定义Automator Action项目连接按钮的已发送操作

我在Xcode的Interface Builder中,创建了一个Cocoa-Applescript自定义Automator Action.我在界面中有一个Button和一个ComboBox菜单.我想在用户单击Button时填充ComboBox菜单的内容值.我创造了

on buttonSentAction_(sender)
    -- set popupMenuContentValues of my parameters() to aList as list
    my popupMenu's addItemsWithObjectValues_(aList)
end buttonSentAction_
Run Code Online (Sandbox Code Playgroud)

在applescript文件中的处理程序,但当我从按钮拖动到文件的所有者时,文件的所有者不会突出显示我放弃连接.我期待的是它放弃并让我选择buttonSentAction_处理程序来接收发送的动作.如果我右键单击File's Owner,我在Applescript控制器文件中创建的收到的操作处理程序不会显示.(注意,我仍然不确定在该处理程序中填充ComboBox菜单的正确行.) 屏幕抓取将组合框链接到文件所有者

我可以在"FM to Named Text Boxes"中看到示例macosxautomation.com上的Automator Action项目在IB中有一个按钮,您可以在Bindings Inspector中看到按钮的发送动作实际上已连接到文件所有者,并且applescript文件具有匹配的处理程序.另外,我默认将File's Owner的控制器设置为applescript文件.显然,我遗漏了一些关于在Automator Action Project中挂起已发送动作的具体内容.有帮助吗?

xcode cocoa applescript automator applescript-objc

5
推荐指数
1
解决办法
2142
查看次数

Applescript打开终端,运行命令和显示 - 不工作

我正在尝试创建一个keyhortcut来打开当前文件夹中的终端.环顾四周,我发现这个代码创建了一个服务(添加了这个服务的快捷方式的部分就解决了),只添加了一些东西是"; clear"和一些"激活"所以它显示

on run {input, parameters}

tell application "Finder"
    activate

    set myWin to window 1

    set theWin to (quoted form of POSIX path of (target of myWin as alias))

    tell application "Terminal"

        activate
        tell window 1
            activate
            do script "cd " & theWin & ";clear"
        end tell

    end tell

end tell


return input

end run
Run Code Online (Sandbox Code Playgroud)

它没有像我想的那样工作.

烦恼:

  • 它在终端打开两个窗口,不知道为什么.它与添加的"激活"无关......它一直都是这样做的
  • 如果我在finder(文件夹)上选择一个项目,它会打开它的父目录,我希望它打开所选的文件夹

这是我对Applescript的第一次尝试,所以如果错误很明显我就是看不到它

提前致谢

applescript automator

5
推荐指数
2
解决办法
2万
查看次数

使用高CPU时通知。通过AppleScript还是Automator?

我想自动化,只要进程使用超过50%的CPU,
它就会向我的通知中心发送通知

我正在使用终端通知程序来发送低谷通知,
但是我对创建此自动化的最佳方法有些困惑。

我应该使用Automator.app还是创建自定义AppleScript?如果是,
如何使它始终处于打开状态?

applescript automation automator cpu-usage

5
推荐指数
1
解决办法
1710
查看次数

删除超过30天的下载?

我正在尝试在automator中创建一个任务,如果它们超过30天,将〜/ Downloads中的文件移动到垃圾箱.

我想让它每天都运行.

它不起作用,Finder只是挂起并停止响应,我必须从活动监视器强制退出它.

on run {input, parameters}

    tell application "Finder"
        set deleteFileList to (files of entire contents of folder alias "Macintosh HD:Users:George:Downloads" whose modification date is less than ((get current date)) - 30 * days)
        try
            repeat with deleteFile in deleteFileList
                delete deleteFile
            end repeat
        end try
    end tell

    return input
end run
Run Code Online (Sandbox Code Playgroud)

macos applescript automation automator

5
推荐指数
1
解决办法
2222
查看次数