在iTunes中找到部分名称的歌曲

时间:2012-11-18 03:22:45

标签: applescript itunes

我知道如何通过名字在播放列表中播放歌曲,但是我想说我想制作它以便在我播放该歌曲时白色空间和大小写无关紧要。

因此,如果我想播放“someSong”,“some song”或“Some Song”,我还想在播放列表中播放名为“Some song”的歌曲。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

尝试:

set yourSong to "yoursongname"
set yourPlaylist to "your playlist"

set searchString to {}
repeat with i from 1 to count of yourSong
    set aChar to text i of yourSong
    if aChar ≠ space then
        set end of searchString to aChar & " *?"
    end if
end repeat
set searchString to searchString as text

tell application "iTunes" to set plTracks to name of every track of playlist yourPlaylist
set AppleScript's text item delimiters to linefeed
set plTracks to plTracks as text
set AppleScript's text item delimiters to {""}
set targetSong to do shell script "echo " & quoted form of plTracks & " | grep -Ei " & quoted form of searchString

log targetSong
display dialog "Now Playing: " & targetSong buttons {"Cancel", "OK"} default button "OK" giving up after 2

tell application "iTunes" to play track targetSong of playlist yourPlaylist
相关问题