0

フォルダ内のファイルを追加または更新するスクリプトがあります。私がやりたいのは、AppleScriptがこれらのファイルをiTunesに追加することです。しかし、私はディレクトリをループすることができないようです。

tell application "iTunes"
  if playlist myPlaylist exists then delete playlist myPlaylist
  set newPlaylist to (make new user playlist with properties {name:myPlaylist})

  repeat with theFile in myPath as list
    add theFile to playlist myPlaylist
  end repeat
end tell

繰り返すたびに、theFileの値はmyPathの個々の文字であり、myPath内の実際のファイルではありません。theFileは、file1.mov、file2.mov、..の代わりにM、a、c、i、n、...になります。

ありがとうございました。

4

1 に答える 1

1

myPathが文字列の場合、文字as listの配列に変換します。

エイリアスのリストを取得するようにFinderに指示できます。

tell application "Finder"
    set l to items of (POSIX file "/Users/username/Music/folder" as alias) as alias list
end tell
tell application "iTunes"
    if playlist "test" exists then
        delete tracks of playlist "test"
    else
        set p to make new user playlist with properties {name:"test"}
    end if
    add l to p
end tell

これにより、選択したファイルが現在表示されているプレイリストに追加されます。

tell application "Finder"
    set l to selection as alias list
end tell
tell application "iTunes"
    add l to view of browser window 1
end tell
于 2013-01-03T01:23:23.273 に答える