2014-01-09 56 views
0

當我運行這個AppleScript我得到錯誤(null)。我唯一能想到的就是文件路徑格式不正確。任何幫助,將不勝感激。AppleScript返回空()

on run {input, parameters} 

    set picFolder to alias "Users:cd:Dropbox (Personal):Camera Uploads:" 
    set screenshotFolder to alias "Users:cd:Dropbox (Personal):Camera Uploads:Screenshots:" 

    tell application "System Events" 
     set photos to path of files of picFolder whose kind is "Portable Network Graphics image" 
    end tell 

    set screenshots to {} 
    repeat with imgPath in photos 
     set imgAlias to alias imgPath 
     tell application "Image Events" 
      set img to open imgPath 
      if ((dimensions of img = {640, 1136}) or (dimensions of img = {640, 960}) or (dimensions of img = {1024, 768})) then 
       set end of screenshots to imgAlias 
      end if 
      close img 
     end tell 
    end repeat 

    tell application "Finder" 
     move screenshots to screenshotFolder 
    end tell 


    return input 
end run 

回答

0

主腳本適用於我,但不是如果我在腳本編輯器中運行它的方式。我必須註釋掉{input, parameters}return input,因爲運行處理程序(在此上下文中)不能接受參數(或者您可以更改處理程序的名稱)。如果我這樣做,似乎沒有問題(除了明顯缺乏糾錯,例如,如果文件已經存在等)。你可以使用運行處理程序的參數,但你不能在腳本編輯器中這樣測試它(我假設你最終要從命令行發送參數)。