2011-11-29 63 views
0

我使用下面的AppleScript在我的Automator工作流程:如何創建一個新的文件列表並返回它們?

on run {input, parameters} 
    --say input 
    set result_array to {} as list 
    try 
     repeat with this_file in input 
      tell application "Image Events" 
       launch 
       set this_image to open this_file 
       copy dimensions of this_image to {W, H} 
       close this_image 
      end tell 

      set text item delimiters to ":" 
      set file_name to last text item of (this_file as string) 
      set text item delimiters to "" 
      set filter_string to W & "x" & H as string 

      if file_name contains filter_string then 
       set the end of result_array to this_file 
      end if 
    end repeat 
    return result_array 
    on error error_message 
     display dialog error_message 
    end try 
end run 

的腳本Get Folder Contents動作後運行。

結果數組有問題,但我找不出什麼。 結果必須是名稱中包含其大小的文件列表。

+0

請詳細解釋一下。 – gadgetmo

+0

我想''result_array'中的具體'this_file',但它沒有工作。 – Phil

回答

2

如果我理解正確使用下列之一:

if file_name contains filter_string then 
-- set the end of result_array to this_file as alias 
-- set the end of result_array to this_file as text 
end if 

目前this_file就像是一個指向文件的原始列表。直接使用時,它包含當前值的索引和完整列表。

這可能是由於repeat with a in b是如何在Applescript中實現的。

+0

謝謝!這正是我需要的。 :) – Phil

相關問題