2013-12-13 42 views
-1

所以我有一个朋友,我试图帮忙。他刚买了一台新的MacBook Pro,目前正在经历将iTunes中的所有音频文件转换为“.mp3”扩展名的过程。 Afterwords,他将这些文件移动到一个外部设备(它出于某种原因不会播放“.m4a”),然后他想删除.mp3s。我在AppleScript方面没有任何经验,但我想知道是否有人有任何编写删除某种类型的所有文件的脚本的经验。任何帮助深表感谢。使用AppleScript删除iTunes中的设置文件

+1

你阅读本:http://stackoverflow.com/questions/15281869/delete-pdf-files-only-from-folder -using-applescript-on-mac – Kara

+0

那么大概它可能是这样简单的: 告诉应用程序“iTunes”要删除(文件夹“路径在这里”的文件扩展名是“mp3”)? 那么,我唯一的问题就是如何执行脚本? AppleScript是否从终端执行? –

+0

你应该试试AppleScript Editor。它在'/ Applications/Utilities'中。 –

回答

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") 
0

这会将所有MP3文件在iTunes资料库的垃圾桶:

tell application "iTunes" to location of tracks where kind is "MPEG audio file" 
tell application "Finder" to move result to trash 

如果所有的MP3文件都在〜/音乐,你也可以运行这样的命令:

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 
相关问题