2013-01-10 33 views
0

我在網上查了幾個小時尋找這個答案,所以我道歉,如果它在那裏。下面的腳本工作正常,除了它返回.DS_Store文件的事實,我怎麼能從這個查詢和所有其他隱藏文件中排除它,但因爲我在腳本中創建了唯一的文件夾.DS_StoreApplescript系統事件返回.DS_Store - 我該如何忽略

告訴應用程序「系統事件」 集listOfInputs到文件夾作爲列表 結束每個磁盤項目的POSIX路徑告訴

這裏是下面的完整劇本。在創建文件夾後,我一直在將文件放入文件夾中,但最終會在文件創建之前提示輸入文件。

上運行

tell application "Finder" 
    if not (exists folder "IN") then 
     make new folder at desktop with properties {name:"IN"} 
    end if 
    if not (exists folder "OUT") then 
     make new folder at desktop with properties {name:"OUT"} 
    end if 
end tell 


set theINfolder to path to the desktop as string 
set a to theINfolder & "IN:" 


tell application "System Events" 
    set listOfInputs to POSIX path of every disk item of folder a as list 
end tell 

set inputs to listOfInputs 

set theOutfolder to path to the desktop as string 
set outputFolder to theOutfolder & "OUT:" 

set params to {} 

main(inputs, outputFolder, params) 

運行結束

回答

0

列表文件夾命令已被棄用,並可能意外停止工作。

嘗試:

set inFolder to (path to desktop as text) & "IN" 
do shell script "mkdir -p " & quoted form of (POSIX path of inFolder) 
set listOfInputs to paragraphs 2 thru -1 of (do shell script ("find " & quoted form of (POSIX path of inFolder) & " \\! -name \".*\"")) 

你可以得到的結果是用空格這樣分開的字符串:

set inFolder to (path to desktop as text) & "IN" 
do shell script "mkdir -p " & quoted form of (POSIX path of inFolder) 
set {TID, text item delimiters} to {text item delimiters, " "} 
set listOfInputs to paragraphs 2 thru -1 of (do shell script ("find " & quoted form of (POSIX path of inFolder) & " \\! -name \".*\"")) as text 
set text item delimiters to TID 
+0

還要感謝。我沒有意識到列表文件夾已被棄用做shell腳本是我第一次嘗試沒有運氣的路線。我懷疑shell腳本很快就會被棄用。你知道我怎樣才能返回一個字符串(不是在一個列表中,但用空格分隔嗎?)的輸入列表,以便在我正在使用的單獨shell腳本中使用? – user1968247

+0

查看編輯的版本... – adayzdone

+0

謝謝tonne ....本網站是偉大的。快速高效。我感謝所有的幫助。 – user1968247

0

下面的工作:

set listOfInputs to list folder a without invisibles 

without invisibles不能POSIX path相結合,所以我們用,而不是一個循環:

set listOfInputs to {} 
tell application "System Events" 
    set the_items to list folder a without invisibles 
    repeat with i from 1 to the count of the_items 
     set this_item to alias ((a as Unicode text) & (item i of the_items)) 
     set end of listOfInputs to POSIX path of this_item 
    end repeat 
end tell 
+0

你做到了...什麼是救濟感謝這麼多 – user1968247

相關問題