我添加到itunes脚本试图添加不支持类型的文件,例如jpg / txt / .thumb等
我想通过以下代码更具体一点,只选择mp3& m4a
tell application "Finder" to set fPaths to paragraphs of ((files of entire contents of iTunesFolder) as Unicode text)
repeat with thisFilePath in fPaths
--processing code goes here
-- maybe I need an if file extension is in... type condition?
end repeat
答案 0 :(得分:2)
我不确定你在第一线上做了什么。但是,如果您可以将thisFilePath强制转换为Finder项,则应该能够获得扩展名。该属性称为名称扩展名。我用桌面上的文件测试了这个:
copy {"pdf", "scpt"} to validExtensions
tell application "Finder" to set fPaths to files of desktop
repeat with thisFilePath in fPaths
if name extension of thisFilePath is in validExtensions then
display dialog thisFilePath as string
end if
end repeat
它只显示那些特别具有 validExtensions 中列出的扩展名的文件。