2016-04-28 8 views
0

AppleScriptをプログラムしているので、自動的にプレフィックスをファイルに付けて、特定のフォルダにコピーしたときにftp- (OS X El Capitanのフォルダアクションとして使用されます)。AppleScriptでプレフィックスを変更し、ファイルがフォルダにコピーされるときに自動的にftpにアップロードする

ファイルが自動的にアップロードされるのですが、実装しようとすると接頭辞(特にUNIXタイムスタンプ)を追加する必要がありますが、ファイル名もftpにもアップロードされません-ディレクトリ。私は、スクリプトがすべてで動作することを疑う

property uploadftp : "ftp://user:password«ftpxyz.de/directory/" --this will be changed to the real one 
set nowSeconds to ((current date) - (date ("1/1/1970")) - (time to GMT)) as miles as string 
set timestamp to nowSeconds & "_" 
set Tag to timestamp 
on adding folder items to this_folder after receiving added_items 
    set thelist to "" 
    repeat with i in added_items 
     set thelist to thelist & return & i & "," 
     try 
      set theFiles to thelist 
      repeat with aFile in theFiles 
       set name of aFile to Tag & name of aFile 
      end repeat 
      do shell script "curl -T " & quoted form of POSIX path of i & space & quoted form of uploadftp 
     on error e number n 
      display dialog "Error: " & e & "Number: " & n 
     end try 
    end repeat 
    display dialog "Dateien empfangen: " & (count added_items) & return & "Ordner: " & POSIX path of this_folder & return & "Dateien: " & thelist 
end adding folder items to 

答えて

0

:それは今あるよう

は、ここに私のコードです。

主な問題は、イベントハンドラ以外のコードは実行時に実行されないことです。今ではそれが必要として完璧に動作し、

私はそんなにあなたに感謝したい
property uploadftp : "ftp://user:password«ftpxyz.de/directory/" --this will be changed to the real one 

on adding folder items to this_folder after receiving added_items 

    set timestamp to ((current date) - (date ("1/1/1970")) - (time to GMT)) as miles as string 

    set thelist to {} 
    repeat with aFile in added_items 
     try 
      set fileName to name of (info for aFile) 
      set newFileName to timestamp & "_" & fileName 
      set end of thelist to fileName 
      do shell script "curl -T " & quoted form of POSIX path of aFile & space & quoted form of (uploadftp & newFileName) 
     on error e number n 
      display dialog "Error: " & e & "Number: " & n 
     end try 
    end repeat 
    set saveTID to AppleScript's text item delimiters 
    set AppleScript's text item delimiters to "," 
    set receivedFiles to thelist as text 
    set AppleScript's text item delimiters to saveTID 
    display dialog "Dateien empfangen: " & (count added_items) & return & "Ordner: " & POSIX path of this_folder & return & "Dateien: " & receivedFiles 
end adding folder items to 
+0

が、それは私をたくさん助けたと私はミスを犯したところ、私は理解して:

はこれを試してみてください!どうもありがとうございました! – H1GHL4ND3R

+0

Keine Ursache(あなたを歓迎します) – vadian

関連する問題