Applescript遍历目录
我有一个脚本,可以添加或更新文件夹中的文件。我想做的是让applescript将这些文件添加到iTunes中。但我似乎无法循环浏览目录Applescript遍历目录,applescript,Applescript,我有一个脚本,可以添加或更新文件夹中的文件。我想做的是让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 wi
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
对于每个重复,文件的值是myPath的单个字符,而不是myPath中的实际文件。文件将是M、a、c、i、n、。。。而不是file1.mov,file2.mov
谢谢。如果
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
你是怎么得到我的路径的?