0
我可以将歌曲列表分为两个单独的列表:一个歌曲标题是三个或更少的词,一个是四个词或更多的歌?我想要一个列表(作为变量)并对其执行一个操作,然后在另一个列表上单独执行一个操作。在Applescript中获得一定长度的段落(然后对这些段落做些什么)
这里的,据我得到:
tell application "TextEdit"
activate
tell the front document
set my_list to every paragraph whose (count of words) is 2
end tell
end tell
我似乎无法得到的单词数的属性在每个段落的工作 - 我收到错误消息:“文字编辑得到了一个错误:无法将2671转换为类型引用。“
这可能有助于解释什么,我接下来要做。
我拿到名单
set MySongs to paragraphs of my_list
-- read artist names (separated by newlines) from the file
的段落,然后将它们添加到iTunes播放列表:
tell application "iTunes"
repeat with AnItem in MySongs -- get all tracks from each artist
set AnItem to (contents of AnItem)
if AnItem is not "" then try -- don't bother with empty names
set MyTracks to (location of file tracks of playlist "Music" whose name is AnItem)
--can also modify the above from "is" to "contains" or "_begins with_"
add MyTracks to NewPlaylist
on error errmess -- oopsie (not found, etc)
log errmess -- just log it
end try
end repeat
end tell
然后做类似的事情与第二个列表。
因此:是否可以从文本文档中获取小于4个单词的段落,并将其转换为以这种方式传递的变量?
感谢
塔迪