2012-02-17 3 views
0

개인 정보를 삭제하도록 수정 된 다음 스크립트가 있습니다.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 

스크립트를 실행할 때 다음 줄이 실패합니다.

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)

사람이 오류가 의미 또는 해결 방법을 무엇을 알고 있나요 다음과 같이

download every remote item to beginning of alias localStorage 

내가 오류는? 나는 행운을 빌어 요없이 Fetch 웹 사이트를 시도했다. "가져 오기"btw는 FTP 클라이언트 가져 오기입니다.

답변

2

은 첫째로 당신은 (예를 들어, log tWindow's remote items으로 이러한 log 문을 추가하고 사람들을 얻을 수 있었다 여부를 스크립트 편집기의 이벤트 로그에보고)이 발생하고있는 remotePath이 정말로 존재하는지 확인해야합니다.

경로가 맞으면 목록 개체 (every remote item...)에 대한 참조와 함께 download 명령을 사용하고있는 것이 문제라고 생각합니다. 설명서에서 명령에 단일 항목의 지정자가 필요합니다.

download specifier : the remote file, remote folder, shortcut, or url to download

그래서 항목을 반복해야합니다. The snippet below 나를 위해 완벽하게 작동합니다 :

-- 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 
+0

감사합니다! 그거야. 또한 "미러 폴더"옵션에 대해 appleScript를 기록 할 수 있음을 발견했습니다. 그로부터 나는 모든 것을 끝내라는 명령을 받았다. –

1

download에 목록을 통과에는 문제가 없습니다.

tell window tWindow 
    download every remote item to beginning of alias localStorage 
    close window 
end tell 
  1. tell 블록은 오히려 transfer window보다 일반적인 window 객체에 동봉 된 명령을 지시하고, 일반 window 객체가 원격 항목을 포함하지 않습니다하지만 원래의 코드 두 가지 문제가있다.
  2. download 명령의 to 매개 변수는 삽입 위치가 아닌 별칭이어야합니다 (예 : beginning of ...).

이 작동합니다 :

tell tWindow 
    download every remote item to alias localStorage 
    close 
end tell 
+0

감사합니다. 저에게 또 다른 문제가 수정되었습니다. :) –

관련 문제