标签: applescript

使用 Automator / Applescript 将图像下载到特定目录

我尝试使用 Automator 中的变量将图像保存到特定文件夹中。

奇怪的是,当您创建一个新文件夹并使用变量时,它允许您设置基本路径...但是如果您尝试“下载 URL”,它不允许您选择要添加变量的基本路径,并且它中断交易。

我确信 applescript 可以做得更好,但我似乎无法弄清楚。

例子。

有一个名为 Cats and Dogs 的照片库。

我可以获取 Cats and Dogs 标题并将其设为我的变量...它在我的桌面上创建了一个名为 Cats and Dogs(来自变量)的新文件夹...然后我可以获取图库中的所有图像作为“从网页获取图像 URL”的结果...

这很好用......然后我尝试“下载 URL”,我想将它们下载到我创建的新“Cats and Dogs”文件夹中。但我似乎无法做到这一点,因为我无法在 automator 的下载 URL 框中设置路径...

当我有 100 个画廊需要翻到我的桌面时,这最终非常有用......

当然,我可以在保存后手动移动新创建的文件夹中的文件……但是我必须为每个画廊都这样做……

有什么建议?

applescript automator

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

在 AppleScript 中复制文件

我有下面的代码在 Applescript 中为 iTunes 音乐文件夹的路径设置一个变量:

set username to text returned of (display dialog "RingtoneDude" default answer "Enter your path to your iTunes Ringtones folder here. e.g. /Users/David/Music/iTunes/iTunes Music/Ringtones" buttons {"Confirm", "Cancel"} default button 1)
Run Code Online (Sandbox Code Playgroud)

然后我有代码来调用变量用户名来复制文件

tell application "Finder"
                copy file theCopy to username
            end tell
Run Code Online (Sandbox Code Playgroud)

但是桌面上的文件 theCopy(theCopy 是一个变量)不会移动到文件夹中。

请帮忙。

directory applescript copy file move

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

初学者:重复 while 循环和错误

好的,所以不确定 apple.stackexchange 是否是一个更好的地方,但我需要一些有关此代码的帮助:

目标:要求用户输入循环应重复的次数。如果他们以错误的格式输入,请发送反馈

问题如果我输入一个小数,它只是把它当作一个整数并且仍然有效,我该如何防止这种情况,或者用另一种方式检查它?

set correctEntry to false --initially assume false
repeat while correctEntry is false
    --Let user put how many times it loops
    set textToDisplay to "How often should this repeat?"
    display dialog textToDisplay default answer "2.4"
    set reps to text returned of the result
    --Detailed check/feedback if they input wrong
    try
        --Begins as string, try making it an integer
        set reps to reps as integer --coercion will should only work with integer
        set correctEntry to …
Run Code Online (Sandbox Code Playgroud)

applescript

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

在运行argv和其他处理程序

我对applescript很新,我不能超越从命令行接受参数的观点.我读过我可以这样做:

on run argv
    log "SOMETHIG
end run

on readLines(unixPath)
    set targetFile to (open for access (POSIX file unixPath))
    set fileText to (read targetFile for (get eof targetFile) as text)
    set fileLines to every paragraph of fileText

    close access targetFile
    return fileLines
end readLines
Run Code Online (Sandbox Code Playgroud)

问题在于它不允许我on run argv与其他函数(或处理程序)一起定义,on而它允许我定义任意数量的函数(除了on run argv).怎么会?

applescript

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

AppleScript 返回带有奇怪字符的文本

我有一个脚本来返回文本文件的一部分,但我注意到它有时会返回直接查看文本文件时不可见的字符。例如,这个词:

breeders
Run Code Online (Sandbox Code Playgroud)

变成

breed‰ rs
Run Code Online (Sandbox Code Playgroud)

我尝试将“作为 Unicode 文本”添加到我的文本返回中,但这不起作用。想法?这是我的脚本:

set some_file to "[...]Words.txt" as alias
set the_text to read some_file as string
set the text item delimiters of AppleScript to ", "
set the_lines to (every text item of the_text)
return some item of the_lines as Unicode text
Run Code Online (Sandbox Code Playgroud)

applescript text character

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

如何通过applescript访问ppt文件中的注释文本?

我想在os x上的PPT文件中获取笔记文本.我觉得这应该工作:

get content of notes page of slide N of active presentation
Run Code Online (Sandbox Code Playgroud)

但它总是会返回"缺失值".有什么想法吗?

顺便说一下,我的目标是能够创建一组幻灯片的新版本,其中笔记不包含文本STUDENT = HIDE ...我喜欢向学生提供幻灯片,但并不总是希望他们看到所有内容提前(例如,课堂练习的正确结果).

powerpoint applescript

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

POSIX 文件错误 - 无关的双引号?

这个applescript有效

set myFile to (POSIX path "/Users/fred/Documents/data.dat")
Run Code Online (Sandbox Code Playgroud)

这个applescript 不起作用

set myFileName to "/Users/fred/Documents/data.dat"
set myFile to (POSIX path myFileName)
Run Code Online (Sandbox Code Playgroud)

它因错误而失败

    get POSIX file "/Users/fred/Documents/data.dat"
    --> error number -1728
Result:
error "iTunes got an error: Can’t get POSIX file \"/Users/fred/Documents/data.dat\"." number -1728 from file "Macintosh HD:Users:drew:Desktop:Music:DIY:DIY-01.mp3"
Run Code Online (Sandbox Code Playgroud)

看起来好像在使用变量时,POSIX 路径在文件名中包含双引号作为显式字符。我究竟做错了什么?

下面的脚本重现了该问题。

tell application "Finder"
    set newFileName to "/Users"
    set newFile to POSIX file newFileName
end tell
Run Code Online (Sandbox Code Playgroud)

谢谢

macos applescript

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

MAC OS - AppleScript - 如何让它显示一次用户名和密码对话框?

你好,

在我的AppleScript中,我正在运行以下代码,

do shell script "sudo networksetup -setproxybypassdomains Ethernet *.local, 169.254/16"
do shell script "sudo networksetup -setwebproxy Ethernet 127.0.0.1 8888"
do shell script "sudo networksetup -setsecurewebproxy Ethernet 127.0.0.1 8888"
Run Code Online (Sandbox Code Playgroud)

但是,它每次都要求输入密码.我的意思是当脚本打开时,它会为每行进程请求密码3次.为了防止要求密码,我必须在终端中键入以下内容,

sudo chmod u + s/usr/sbin/networksetup

当按下Enter键时,它会要求输入密码,输入并运行AppleScript后,它不会再要求输入密码(3次).

但是用户必须转到终端并键入以上命令.为了防止这种情况,我在AppleScript中使用了以下代码,

do shell script "sudo chmod u+s /usr/sbin/networksetup"
Run Code Online (Sandbox Code Playgroud)

因此用户运行AppleScript并自动设置.但是我收到以下错误消息,

在此输入图像描述

如何更改AppleScript,

do shell script "sudo chmod u+s /usr/sbin/networksetup"
Run Code Online (Sandbox Code Playgroud)

...要求输入一次密码,然后执行"... do shell script ..."部分的其余部分而不要求输入密码.或者添加密码以及上面的代码行以使其工作?

macos shell applescript sudo

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

哪个消息可以告诉应用程序?

当我想用Finder做某事时,我使用

tell application "finder"
      do something
   end tell
Run Code Online (Sandbox Code Playgroud)

finder 有没有可以做的功能列表?

还是其他应用?

applescript

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

以编程方式写入 Apple Numbers 电子表格?

是否可以在 iOS/Windows 中以编程方式编写 Apple Numbers 电子表格。?我们正在开发一个应用程序,并希望能够使用用户在预先格式化的电子表格中共享它创建的数据。

请问有什么指点或建议吗?

applescript

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

标签 统计

applescript ×10

macos ×2

automator ×1

character ×1

copy ×1

directory ×1

file ×1

move ×1

powerpoint ×1

shell ×1

sudo ×1

text ×1