所以我有一个朋友,我试图帮忙。他刚买了一台新的MacBook Pro,目前正在将iTunes中的所有音频文件转换为" .mp3" extentsion。后来,他将这些文件移动到外部设备(由于某种原因它不会播放" .m4a")然后他想删除.mp3s。我没有AppleScript的任何经验,但我想知道是否有任何人有任何编写删除某种类型的所有文件的脚本的经验。非常感谢任何帮助。
答案 0 :(得分:0)
你应该真正发布代码,即使它是错误的,也要付出一些努力。但是,这应该让你开始。节日快乐。
set targetFolder to (choose folder)
tell application "Finder" to delete (files of targetFolder whose name extension = "mp3")
或者如果你想递归搜索......
set targetFolder to (choose folder)
tell application "Finder" to delete (files of (entire contents of targetFolder) whose name extension = "mp3")
答案 1 :(得分:0)
这会将iTunes资料库中的所有mp3文件移至垃圾箱:
tell application "iTunes" to location of tracks where kind is "MPEG audio file"
tell application "Finder" to move result to trash
如果所有mp3文件都在〜/ Music中,您还可以运行如下命令:
find ~/Music -name \*.mp3 -delete
此脚本删除未在iTunes资料库中找到文件的曲目:
tell application "iTunes"
repeat with t in (get file tracks of library playlist 1)
if location of t is missing value then delete t
end repeat
end tell