如何使用Fetch和applescript下载所有文件?
我有以下脚本(修改以删除任何私人信息) 当我运行脚本时,下面一行失败如何使用Fetch和applescript下载所有文件?,applescript,fetch,Applescript,Fetch,我有以下脚本(修改以删除任何私人信息) 当我运行脚本时,下面一行失败 download every remote item to beginning of alias localStorage 我得到的错误如下: 错误“获取获取错误:无法获取窗口的每个远程项(传输窗口id 232280960)。”编号-1728来自窗口的每个远程项(传输窗口id 232280960) 有人知道错误的含义或修复方法吗?我已经尝试了Fetch网站,但运气不太好。“Fetch”btw是Fetch FTP客户端。首先,
download every remote item to beginning of alias localStorage
我得到的错误如下:
错误“获取获取错误:无法获取窗口的每个远程项(传输窗口id 232280960)。”编号-1728来自窗口的每个远程项(传输窗口id 232280960)
有人知道错误的含义或修复方法吗?我已经尝试了Fetch网站,但运气不太好。“Fetch”btw是Fetch FTP客户端。首先,您应该检查您正在生成的
远程路径是否确实存在(例如,通过添加log
语句,例如log tWindow的远程项
,并在脚本编辑器的事件日志中查找是否能够获取这些项)
如果路径正确,我认为问题在于您使用的是download
命令引用了一个列表对象(每个远程项…
)。在文档中,该命令需要单个项的说明符:
下载说明符:要下载的远程文件、远程文件夹、快捷方式或url
这就是为什么需要循环浏览这些项目。非常适合我:
-- my settings for testing
set theHost to "ftp.fetchsoftworks.com"
set loginName to "anonymous"
set remotePath to "/example/"
set localStorage to ((path to home folder) as text) & "LOCALSTORAGE:1234567890:"
-- Connect to FTP
tell application "Fetch"
activate
set tWindow to make new transfer window at beginning with properties {hostname:theHost, username:loginName, initial folder:remotePath}
set localStorage to (localStorage as alias)
repeat with theItem in tWindow's remote items
try
download theItem to localStorage
end try
end repeat
close tWindow
quit
end tell
首先,您应该检查您正在生成的remotePath
是否确实存在(例如,通过添加log
语句,例如log tWindow的remote items
,并在脚本编辑器的事件日志中查找是否能够获取这些项)
如果路径正确,我认为问题在于您使用的是download
命令引用了一个列表对象(每个远程项…
)。在文档中,该命令需要单个项的说明符:
下载说明符:要下载的远程文件、远程文件夹、快捷方式或url
这就是为什么需要循环浏览这些项目。非常适合我:
-- my settings for testing
set theHost to "ftp.fetchsoftworks.com"
set loginName to "anonymous"
set remotePath to "/example/"
set localStorage to ((path to home folder) as text) & "LOCALSTORAGE:1234567890:"
-- Connect to FTP
tell application "Fetch"
activate
set tWindow to make new transfer window at beginning with properties {hostname:theHost, username:loginName, initial folder:remotePath}
set localStorage to (localStorage as alias)
repeat with theItem in tWindow's remote items
try
download theItem to localStorage
end try
end repeat
close tWindow
quit
end tell
将列表传递到下载
没有问题。但原始代码有两个问题:
tell window tWindow
download every remote item to beginning of alias localStorage
close window
end tell
tell
块将附带的命令定向到通用窗口
对象,而不是传输窗口
,并且通用窗口
对象不包含远程项
download
命令的to
参数应该是别名,而不是插入位置(例如,开头…
)
这应该起作用:
tell tWindow
download every remote item to alias localStorage
close
end tell
将列表传递到下载
没有问题。但原始代码有两个问题:
tell window tWindow
download every remote item to beginning of alias localStorage
close window
end tell
tell
块将附带的命令定向到通用窗口
对象,而不是传输窗口
,并且通用窗口
对象不包含远程项
download
命令的to
参数应该是别名,而不是插入位置(例如,开头…
)
这应该起作用:
tell tWindow
download every remote item to alias localStorage
close
end tell
谢谢这很有效。我还发现您可以录制“镜像文件夹”选项的appleScript。从那以后,我得到命令把所有的东西都拉过来。谢谢!这很有效。我还发现您可以录制“镜像文件夹”选项的appleScript。从那以后,我得到命令,把所有东西都拉过来。谢谢吉姆。这为我解决了另一个问题。:)谢谢你,吉姆。这为我解决了另一个问题。:)