iTunesのすべての曲名をtxtドキュメントに書き込もうとしています。私が抱えていた最初の問題は、操作を正しくループできないように見えることでした。以下は、iTunes の最初の 15 曲のテスト ケースです。
tell application "TextEdit"
make new document
end tell
tell application "iTunes"
set trNameID1 to name of track 1
set trNameID2 to name of track 2
set trNameID3 to name of track 3
set trNameID4 to name of track 4
set trNameID5 to name of track 5
set trNameID6 to name of track 6
set trNameID7 to name of track 7
set trNameID8 to name of track 8
set trNameID9 to name of track 9
set trNameID10 to name of track 10
set trNameID11 to name of track 11
set trNameID12 to name of track 12
set trNameID13 to name of track 13
set trNameID14 to name of track 14
set trNameID15 to name of track 15
tell application "TextEdit"
set text of document 1 to {trNameID1 & "
", trNameID2 & "
", trNameID3 & "
", trNameID4 & "
", trNameID5 & "
", trNameID6 & "
", trNameID7 & "
", trNameID8 & "
", trNameID9 & "
", trNameID10 & "
", trNameID11 & "
", trNameID12 & "
", trNameID13 & "
", trNameID14 & "
", trNameID15} as text
end tell
end tell
ループしようとすると、txt ドキュメントには最後の曲名しか含まれていません。たとえば、次のようになります。
tell application "TextEdit"
make new document
end tell
tell application "iTunes"
set trNum to 1
repeat 15 times
set trNameID to name of track (trNum)
tell application "TextEdit"
set text of document 1 to trNameID & "
"
end tell
end repeat
end tell
これにより、15 番目の曲の名前のみが txt ドキュメントに出力されます。
これは非常に基本的なことかもしれませんが、文字通り約 48 時間 AppleScript を使用しており、これを理解できないようです。C++ で文字列を読み取って分析できるように、すべての曲名を txt ドキュメントに入れたいと考えています。誰にもアイデアはありますか?
また、AppleScript で、iTunes ライブラリ全体を調べて最後の曲を確認し、その曲の ID を iTunes に記録し、その ID を通過する繰り返しループを作成する方法があるかどうかはわかりません。このようにして、ライブラリにある曲の数だけループが機能します。
どんなアイデアでも大歓迎です!