• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Viele hassen ihn, manche schwören auf ihn, wir aber möchten unbedingt sehen, welche Bilder Ihr vor Eurem geistigen Auge bzw. vor der Linse Eures iPhone oder iPad sehen könnt, wenn Ihr dieses Wort hört oder lest. Macht mit und beteiligt Euch an unserem Frühjahrsputz ---> Klick

AppleScript für die neuen Sortierfelder

muetze

Zuccalmaglios Renette
Registriert
16.05.06
Beiträge
255
Ich hab auch schon eins geschrieben - aber noch nicht veröffentlicht. hat aber bestimmt noch fehler und ist verbesserungsfähig (Nachfragen etc. bei z. B. "Mann, Manfred & the Earthband" - oder so ähnlich). Ich habe auch alle anderen "tollen" "Künsler" wie z. B. "Michael Jackson" unter "Jackson, Michael" als Artist einsortiert.

muetze

Code:
(*
Changes artist "Beatles, The" to "The Beatles"
AND put "Beatles, The" as sort artist, so that he Beatles will be sortet by "B"

The Artist-Tag must have no leading and trailing blanks.
*)


-- reportin progress every ... tracks
property progress_factor : 50

tell application "iTunes"
	
	if selection is {} then
		display dialog "Please select some tracks."
	else
		
		set this_selection to selection
		set totalTracks to (count this_selection's items)
		display dialog (totalTracks as string) & " tracks to change Names."
		
		-- for progress report
		set all_checked_tracks to 0
		
		-- no idea what this is for
		set oldfi to fixed indexing
		set fixed indexing to true
		
		-- loop over all tracks in playlist
		-- backwards, count of tracks of the playlist is decreasing
		repeat with t from totalTracks to 1 by -1
			
			-- read track
			set this_track to item t of this_selection
			-- read it's comment
			set artist_name to artist of this_track
			
			-- test, if track must be changed
			if artist_name contains "," then
				
				-- old artist_name becomes new_sort_artist_name
				set sort artist of this_track to artist_name
				
				-- change name before and behind ","
				set komma_found to false
				set i to 1
				repeat until komma_found
					if text i of artist_name is equal to "," then
						set komma_found to true
					else
						set i to i + 1
					end if
				end repeat
				
				-- name behind "," & then before ","
				set artist of this_track to (text (i + 2) thru -1 of artist_name) & " " & (text 1 thru (i - 1) of artist_name)
				
			end if
			
			set all_checked_tracks to all_checked_tracks + 1
			
			-- reporting progress
			if frontmost then
				if (progress_factor is not 0) and (all_checked_tracks mod progress_factor) is 0 then
					if frontmost is true then display dialog (all_checked_tracks as string) & " tracks checked..." buttons {«data utxt266B»} giving up after 1
				end if
			end if
			
		end repeat
		
		-- no idea what this is for
		set fixed indexing to oldfi
		
		-- reporting success
		display dialog "finished name changing"
		
	end if
	
end tell
 
Zuletzt bearbeitet:

Skeeve

Pomme d'or
Registriert
26.10.05
Beiträge
3.120
Naja... Dann bräuchte ich meins ja nicht zu posten ;-/
(*
"Set Sort Tag" for iTunes
written by Skeeve adapted from a Script by Doug Adams
-- based on the "Replace Text..." AppleScripts provided
-- by Apple
-- http://www.apple.com/applescript/itunes/index.html"
*)

property tags : {"Sort Album", "Sort Artist", "Sort Album Artist", "Sort Name", "Sort Composer", "Sort Show"}
property tag_text : ""

tell application "iTunes"
   set this_playlist to view of front browser window
   set this_playlist_name to name of this_playlist
   
   set these_tracks to {}
   
   set dd_tracks to "all tracks in \"" & this_playlist_name & "\""
   with timeout of 30000 seconds
      if selection of front browser window is not {} then
         set these_tracks to selection of front browser window
         set dd_tracks to "the selected tracks in \"" & this_playlist_name & "\""
      end if
   end timeout
   
   -- which tag?
   set my_choice to choose from list tags with prompt "Choose the tag to set in " & dd_tracks & "..." without empty selection allowed
   if my_choice is false then return
   set my_choice to first item of my_choice
   
   -- get tag_text string -- blank not okay
   repeat
      set tag_text to text returned of (display dialog ("Set the " & my_choice & " tag of " & dd_tracks & " for text:") default answer tag_text)
      if tag_text is not "" then exit repeat
   end repeat
   
   -- make life easier: faster access via a ref to
   set these_tracks_ref to a reference to these_tracks
   
   set fixed indexing to true
   with timeout of 30000 seconds
      
      if my_choice is "Sort Album" then
         repeat with i from 1 to count of these_tracks_ref
            try
               set sort album of item i of these_tracks_ref to tag_text
            end try
         end repeat
      end if
      
      if my_choice is "Sort Artist" then
         repeat with i from 1 to count of these_tracks_ref
            try
               set sort artist of item i of these_tracks_ref to tag_text
            end try
         end repeat
      end if
      
      if my_choice is "Sort Album artist" then
         repeat with i from 1 to count of these_tracks_ref
            try
               set sort album artist of item i of these_tracks_ref to tag_text
            end try
         end repeat
      end if
      
      if my_choice is "Sort Name" then
         repeat with i from 1 to count of these_tracks_ref
            try
               set sort name of item i of these_tracks_ref to tag_text
            end try
         end repeat
      end if
      
      if my_choice is "Sort Composer" then
         repeat with i from 1 to count of these_tracks_ref
            try
               set sort composer of item i of these_tracks_ref to tag_text
            end try
         end repeat
      end if
      
      if my_choice is "Sort Show" then
         repeat with i from 1 to count of these_tracks_ref
            try
               set sort show of item i of these_tracks_ref to tag_text
            end try
         end repeat
      end if
      
   end timeout
   set fixed indexing to false
   beep
end tell