我有以下脚本(修改为删除任何私人信息)。如何使用Fetch和applescript下载所有文件?
-- This line is for testing.
set the clipboard to "1234567890"
set loginName to "username"
-- Password is stored in KeyChain (you need to do manually).
-- Create Remote path
set folderNumber to the clipboard as string
set subdir1 to character 1 of folderNumber
set subdir2 to character 2 of folderNumber
set remotePath to "/files/" & subdir1 & "/" & subdir2 & "/" & folderNumber
-- Create Local path
set homeFolder to (path to home folder) as string
set localPath to homeFolder & "LOCALSTORAGE" as string
set localStorage to localPath & ":" & folderNumber & ":" as string
-- Create Local file
tell application "Finder"
try
make new folder at localPath with properties {name:folderNumber}
on error e number n
-- Do nothing.
end try
end tell
-- Connect to FTP
tell application "Fetch"
activate
set tWindow to make new transfer window at beginning with properties {hostname:"ftpServerAddress", username:loginName, initial folder:remotePath}
tell window tWindow
download every remote item to beginning of alias localStorage
close window
end tell
quit
end tell
-- Open folder
tell application "Finder"
open localStorage
end tell
当我运行脚本时,下面一行失败。
download every remote item to beginning of alias localStorage
我得到的错误如下:
error "Fetch got an error: Can’t get every remote item of window (transfer window id 232280960)." number -1728 from every remote item of window (transfer window id 232280960)
有谁知道什么错误意味着或如何解决呢?我尝试了Fetch网站,但没有多少运气。 “取”btw是取FTP客户端。
谢谢!这样可行。我还发现你可以记录“镜像文件夹”选项的AppleScript。从那里我得到了一个指令来把所有东西都拉过来。 – 2012-02-17 10:58:10