• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Duplicates files in iTunes after running applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Duplicates files in iTunes after running applescript


  • Subject: Re: Duplicates files in iTunes after running applescript
  • From: Paul Taylor <email@hidden>
  • Date: Sat, 03 Jan 2009 22:54:27 +0000

Axel Luttgens wrote:
Le 31 déc. 08 à 12:33, Paul Taylor a écrit :

Hi, I have created some applescript, that creates a playlist of all the files I have modified outside of iTunes, part of the reason for doing this is that iTunes then has updated metadata information for these files without having to select 'Get Info' within iTunes. The trouble is that for some reason some (but not most) of the files now appear in iTunes twice both referring to the exactly same physical file.

Can anybody see what is going wrong

The problem might be with the use of the "add" command, as it somehow behaves like a kind of import command.
So, even if the file being added already is in your "iTunes Music" folder, iTunes may decide that it needs to create an additional track for that file.
I don't know which criterions are taken into account by iTunes; but the behavior should also depend on some settings in iTunes' preferences.



thanks Paul

example applescript

tell app "iTunes"
set new_playlist to (make user playlist with properties {name:"newList12/20/08 4:01 PM"})
add(POSIX file "/Users/renaudg/Music/iTunes/iTunes Music/Astral Projection/Another World/09 Still on mars.mp3") to new_playlist
add(POSIX file "/Users/renaudg/Music/iTunes/iTunes Music/U2/October/03 I Threw A Brick Through A Window.mp3") to new_playlist
add(POSIX file "/Users/renaudg/Music/iTunes/iTunes Music/Emilie Simon/Emilie Simon (bonus disc)/01 Desert (english version).mp3") to new_playlist
repeat with nexttrack in (get every track of new_playlist)
refresh nexttrack
end repeat
end tell

The safe way would be to refresh the existing tracks, the ones whose files already are in the "iTunes Music" folder.
Unfortunately, I couldn't devise a valid whose clause based on the location property of file tracks.
So, here's the slow way:


set L to {"/Users/renaudg/Music/iTunes/iTunes Music/Astral Projection/Another World/09 Still on mars.mp3","/Users/renaudg/Music/iTunes/iTunes Music/U2/October/03 I Threw A Brick Through A Window.mp3","/Users/renaudg/Music/iTunes/iTunes Music/Emilie Simon/Emilie Simon (bonus disc)/01 Desert (english version).mp3"}
tell application "iTunes"
repeat with T in file tracks
if POSIX path of (get location of T) is in L then
refresh T
end if
end repeat
end tell


But I'm not really well versed in scripting iTunes...
Thanks for the idea but I want to create the playlist, AND Your method iterates through every track in iTunes, of course if the iTunes library is large and Im only updating a few files this isnt very efficient and could be very slow. Could I use the 'duplicate' command to somehow add the tracks to the playlist instead.

Paul

Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Excel 2008 - 'Autofit' broken?
  • Next by Date: Re: Scripting TextEdit
  • Previous by thread: Re: Excel 2008 - 'Autofit' broken?
  • Next by thread: Re: Scripting TextEdit
  • Index(es):
    • Date
    • Thread