如何防止 iTunes 将转换后的 Mp3 添加到库中?

如何防止 iTunes 将转换后的 Mp3 添加到库中?

当我使用 iTunes 将购买的歌曲创建为 Mp3 文件时,iTunes 也会将它们添加到我的资料库中,我得到了两次。我如何才能阻止 iTunes 将转换后的 Mp3 文件添加到资料库中?

编辑:
我在 Mac OS X 上使用 iTunes

编辑2:
克里斯·约翰森回答非常好,值得一试。不过,我也尝试过这个脚本克里斯向我指出了这一点,这更好,从现在起我会使用它。谢谢大家。

答案1

如果您同意暂时将转换后的曲目保留在您的iTunes库,您可以使用 AppleScript 转换曲目,删除对转换后的曲目的引用,最后将转换后的文件移动到您喜欢的任何位置。

普通的 AppleScript 几乎无法提供流畅的用户界面,但以下脚本可能会满足您的需求。将其粘贴到脚本编辑器(或者AppleScript 编辑器在 Snowy 上),并将其保存为“应用程序包”(在 Snowy 上为“应用程序”)。要使用它,请配置您的转换设置(导入设置) 在iTunes,选择一些曲目iTunes,然后将文件夹放在保存的应用程序上。请注意,新转换的文件将覆盖放置文件夹中的现有文件(如果它们的名称相同)。除非您确定要覆盖任何可能的文件,否则最好放置空文件夹。您甚至可能会从该过程中获得一些 ID3v2 标签(我在一些测试中确实这样做了,但这取决于iTunes决定做什么)。

on run
 display dialog "Drop a folder on this application to convert iTune's selected tracks and place them the dropped folder." & return & return & "The converted files will be whatever is selected in iTunes “Import Settings”." with title "About"
 return

 -- Test invocation:
 "/tmp/convert_to_external"
 alias POSIX file result
 open {result}
end run
on open theItems
 if length of theItems is 0 then
  display dialog "No items dropped? Only a single, plain folder should be dropped." with title "Error: Drop Only a Single Folder"
  return
 end if
 if length of theItems is greater than 1 then
  display dialog "Too many items have been dropped. Only a single, plain folder should be dropped." with title "Error: Drop Only a Single Folder"
  return
 end if
 set theItem to first item of theItems
 set info to info for theItem
 if not folder of info or package folder of info then
  display dialog "“" & POSIX path of theItem & "” is not a plain folder. Only a single, plain folder should be dropped." with title "Error: Drop Only a Single Folder"
  return
 else
  |convert iTunes selection into folder|(theItem)
 end if
end open
to |convert iTunes selection into folder|(folderRef)
 try
  do shell script "test -d " & quoted form of POSIX path of folderRef
 on error m
  display dialog "Destination (" & destinationForShell & ") not accessible?" & return & m
  return
 end try

 tell application "iTunes"
  set trackList to selection
  repeat with selectedTrack in trackList
   try
    set convertedTrack to my convertTrack(selectedTrack)
    set convertedFile to location of convertedTrack
    my deleteTrackReference(convertedTrack) -- only delete the iTunes ref, not the track's file
    my moveItemToFolder(convertedFile, folderRef)
   on error m
    tell me to display dialog m with title "Error During Conversion/Removal/Move" -- giving up after 30
   end try
  end repeat
 end tell
end |convert iTunes selection into folder|
to convertTrack(aTrack)
 if class of aTrack is list then error "Must pass a single track."
 using terms from application "iTunes"
  set questionTimeout to 10
  set conversionTimeout to 600
  display dialog "About to start conversion of “" & name of aTrack & "”. Select a timeout in seconds for the conversion (conversion will auto-start in " & questionTimeout & " seconds):" default answer conversionTimeout with title "Conversion Time Limit" giving up after questionTimeout
  try
   set conversionTimeout to (text returned of result) as number
  end try

  set convertedTrack to missing value
  with timeout of conversionTimeout seconds -- conversion may take longer than the deafult 120 second AppleEvent RPC timeout
   try
    set convertedTrack to convert aTrack
   on error
    error "Error while converting track."
   end try
  end timeout
  if convertedTrack is not missing value then return first item of convertedTrack
  error "Abandoning track conversion after timeout." & return & m
 end using terms from
end convertTrack
to deleteTrackReference(aTrack)
 try
  tell application "iTunes" to set mainLibrary to ¬
   first library playlist of (first source whose kind is library)
 on error
  error "Unable to find main library playlist object."
 end try
 using terms from application "iTunes"
  try
   set convertedTrackInMainLibrary to ¬
    (first track of mainLibrary whose database ID is (get database ID of aTrack))
  on error
   error "Unable to find track object in main library playlist."
  end try
  try
   delete convertedTrackInMainLibrary -- deletes the reference, not the actual file
  on error
   error "Unable to delete track from main library playlist."
  end try
 end using terms from
end deleteTrackReference
to moveItemToFolder(itemRef, folderRef)
 set itemPath to POSIX path of itemRef
 set folderPath to POSIX path of folderRef
 try
  do shell script "mv " & quoted form of itemPath & " " & quoted form of folderPath
 on error m
  error "Unable to move item (" & itemPath & ") to destination (" & folderPath & "):" & return & m
 end try
end moveItemToFolder

答案2

据我所知,没有办法做到这一点。您可能想使用其他应用程序(如 Quicktime 或 AudialHub)来进行转换。您想保留原始文件还是 iTunes 中的新文件?您可以创建智能播放列表,以帮助您将其中一个文件收集到一个列表中,以便一步从库中删除它们(在 OS X 中为选择删除)。

答案3

将创建的 MP3 文件移动到 iTunes 将扫描新内容的树之外的另一个目录。

我假设您使用 MP3 以外的其他格式作为主要音频格式,因此请创建一个批处理作业,将 iTunes 目录树中的任何 MP3 内容移动到单独的位置。

例如,使用ROBOCOPY.EXE来执行以下操作:

c:\windows\robocopy c:\itunes-path c:\mp3-files *.mp3 /s /zb /mov /xo

此命令将移动所有子目录中的 MP3 文件,除非目标已经存在且源较旧。您可以将其添加/mot:5到末尾,以便每 5 分钟重复一次。

答案4

编辑:我建议了一些通用的解决方案,但 iTunes 似乎没有任何必要的功能,所以我删除了这些建议。

相关内容