Applescript 选择特定扩展名的文件
我的添加到 itunes 脚本正在尝试添加不支持的类型的文件,例如 jpg/txt/.thumb 等
我想更具体地使用下面的代码仅选择 mp3 和 mp3。米4a
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
My add to itunes script is trying to add files of unsupported types such as jpg/txt/.thumb etc
I would like to be a bit more specific with the below code to only select 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你对第一行做了什么。但如果您可以将 thisFilePath 强制转换为 Finder 项目,则应该能够获得扩展名。该属性称为名称扩展。我已经用桌面上的文件对此进行了测试:
它将仅显示那些具有 validExtensions 中列出的扩展名的文件。
I’m not sure what you’re doing with that first line. But if you can coerce thisFilePath into a Finder item, you should be able to get the extension. The property is called name extension. I’ve tested this with the files on my desktop:
It will display only those files that specifically have an extension listed in validExtensions.