6
我想弄清楚如何在AppleScript中逐行遍歷文件。類似於這樣的bash腳本:在AppleScript中逐行掃描文件?
for LINE in $(cat file)
do
echo ${LINE}
done
任何提示?謝謝!
我想弄清楚如何在AppleScript中逐行遍歷文件。類似於這樣的bash腳本:在AppleScript中逐行掃描文件?
for LINE in $(cat file)
do
echo ${LINE}
done
任何提示?謝謝!
我不記得寫這個,我在MacRumors論壇上從response to a post提起代碼。
tell application "Finder"
set Names to paragraphs of (read (choose file with prompt "Pick text file containing track names"))
repeat with nextLine in Names
if length of nextLine is greater than 0 then
--Do something with the next name, which is stored in "nextLine"
end if
end repeat
end tell
MacRumors論壇上的原始代碼積分爲HexMonkey。
有沒有必要告訴Finder做這些事情。您應該將所有代碼從Finder tell塊中取出。 Applescript可以自己處理這些代碼,Finder經常忙於其他任務,所以它甚至可能會減慢代碼的速度。 – regulus6633 2010-07-23 16:40:58
很高興知道。我真的應該自己學習這些日子之一。 :P – kdmurray 2010-07-23 18:47:22