Skip to main content
format code
Source Link
mmmmmm
  • 31k
  • 18
  • 94
  • 158

I just use a quick and dirty AppleScript to do things like this: -- BP Jan 2014 -- Trims a set number of characters from the Start of track names in an iTunes playlist -- Or trims a set number of characters from the End of track names in a playlist -- Or adds a prefix to each track name in a playlist. -- Or adds a suffix to each track name in a playlist. -- Trims take precedence over adds -- It's best to do just one operation at a time, and set all the other variables to "" or 0 as appropriate. --------------------------------- User settable variables set PlaylistName to "AAA" -- Just add the tracks you want to change to a single playlist. When dione, delete the playlist. set trimInitialchars to 0 -- nonzero value takes precedence over any addstart value set trimFinalchars to 0 set addstart to "" -- nonempty value wil overide addend set addend to "" --------------------------------- End of user settable variables set trimstart to trimInitialchars + 1 tell application "iTunes" activate set tracklst to every track of playlist PlaylistName set trackcount to number of items in tracklst repeat with n from 1 to trackcount -- Do the whole playlist: set oldtitle to name of track named (name of item n of tracklst) if trimInitialchars is greater than 0 then -- Trim stuff from front of track names set name of (item n of tracklst) to (characters trimstart through length of oldtitle) as text else if trimFinalchars is greater than 0 then -- Trim stuff from front of track names set name of (item n of tracklst) to (characters 1 through ((length of oldtitle) - trimFinalchars) of oldtitle) as text else if addstart is not "" then -- Add something to front of track names set name of (item n of tracklst) to (addstart & oldtitle) else if addend is not "" then -- Add something to end of track names set name of (item n of tracklst) to (oldtitle & addend) end if end repeat end tell`

-- BP Jan 2014
-- Trims a set number of characters from the Start of track names in an iTunes playlist
-- Or trims a set number of characters from the End of track names in a playlist
-- Or adds a prefix to each track name in a playlist.
-- Or adds a suffix to each track name in a playlist.
-- Trims take precedence over adds
-- It's best to do just one operation at a time, and set all the other variables to "" or 0 as appropriate.
--------------------------------- User settable variables
set PlaylistName to "AAA" -- Just add the tracks you want to change to a single playlist. When dione, delete the playlist.
set trimInitialchars to 0 -- nonzero value takes precedence over any addstart value
set trimFinalchars to 0
set addstart to "" -- nonempty value wil overide addend
set addend to ""
--------------------------------- End of user settable variables
set trimstart to trimInitialchars + 1
tell application "iTunes"
    activate
    set tracklst to every track of playlist PlaylistName
    set trackcount to number of items in tracklst
    repeat with n from 1 to trackcount -- Do the whole playlist:
        set oldtitle to name of track named (name of item n of tracklst)
        if trimInitialchars is greater than 0 then -- Trim stuff from front of track names
            set name of (item n of tracklst) to (characters trimstart through length of oldtitle) as text
        else if trimFinalchars is greater than 0 then -- Trim stuff from front of track names
            set name of (item n of tracklst) to (characters 1 through ((length of oldtitle) - trimFinalchars) of oldtitle) as text
        else if addstart is not "" then -- Add something to front of track names
            set name of (item n of tracklst) to (addstart & oldtitle)
        else if addend is not "" then -- Add something to end of track names
            set name of (item n of tracklst) to (oldtitle & addend)
        end if
    end repeat
end tell`

I just use a quick and dirty AppleScript to do things like this: -- BP Jan 2014 -- Trims a set number of characters from the Start of track names in an iTunes playlist -- Or trims a set number of characters from the End of track names in a playlist -- Or adds a prefix to each track name in a playlist. -- Or adds a suffix to each track name in a playlist. -- Trims take precedence over adds -- It's best to do just one operation at a time, and set all the other variables to "" or 0 as appropriate. --------------------------------- User settable variables set PlaylistName to "AAA" -- Just add the tracks you want to change to a single playlist. When dione, delete the playlist. set trimInitialchars to 0 -- nonzero value takes precedence over any addstart value set trimFinalchars to 0 set addstart to "" -- nonempty value wil overide addend set addend to "" --------------------------------- End of user settable variables set trimstart to trimInitialchars + 1 tell application "iTunes" activate set tracklst to every track of playlist PlaylistName set trackcount to number of items in tracklst repeat with n from 1 to trackcount -- Do the whole playlist: set oldtitle to name of track named (name of item n of tracklst) if trimInitialchars is greater than 0 then -- Trim stuff from front of track names set name of (item n of tracklst) to (characters trimstart through length of oldtitle) as text else if trimFinalchars is greater than 0 then -- Trim stuff from front of track names set name of (item n of tracklst) to (characters 1 through ((length of oldtitle) - trimFinalchars) of oldtitle) as text else if addstart is not "" then -- Add something to front of track names set name of (item n of tracklst) to (addstart & oldtitle) else if addend is not "" then -- Add something to end of track names set name of (item n of tracklst) to (oldtitle & addend) end if end repeat end tell

I just use a quick and dirty AppleScript to do things like this:`

-- BP Jan 2014
-- Trims a set number of characters from the Start of track names in an iTunes playlist
-- Or trims a set number of characters from the End of track names in a playlist
-- Or adds a prefix to each track name in a playlist.
-- Or adds a suffix to each track name in a playlist.
-- Trims take precedence over adds
-- It's best to do just one operation at a time, and set all the other variables to "" or 0 as appropriate.
--------------------------------- User settable variables
set PlaylistName to "AAA" -- Just add the tracks you want to change to a single playlist. When dione, delete the playlist.
set trimInitialchars to 0 -- nonzero value takes precedence over any addstart value
set trimFinalchars to 0
set addstart to "" -- nonempty value wil overide addend
set addend to ""
--------------------------------- End of user settable variables
set trimstart to trimInitialchars + 1
tell application "iTunes"
    activate
    set tracklst to every track of playlist PlaylistName
    set trackcount to number of items in tracklst
    repeat with n from 1 to trackcount -- Do the whole playlist:
        set oldtitle to name of track named (name of item n of tracklst)
        if trimInitialchars is greater than 0 then -- Trim stuff from front of track names
            set name of (item n of tracklst) to (characters trimstart through length of oldtitle) as text
        else if trimFinalchars is greater than 0 then -- Trim stuff from front of track names
            set name of (item n of tracklst) to (characters 1 through ((length of oldtitle) - trimFinalchars) of oldtitle) as text
        else if addstart is not "" then -- Add something to front of track names
            set name of (item n of tracklst) to (addstart & oldtitle)
        else if addend is not "" then -- Add something to end of track names
            set name of (item n of tracklst) to (oldtitle & addend)
        end if
    end repeat
end tell`
Source Link

I just use a quick and dirty AppleScript to do things like this: -- BP Jan 2014 -- Trims a set number of characters from the Start of track names in an iTunes playlist -- Or trims a set number of characters from the End of track names in a playlist -- Or adds a prefix to each track name in a playlist. -- Or adds a suffix to each track name in a playlist. -- Trims take precedence over adds -- It's best to do just one operation at a time, and set all the other variables to "" or 0 as appropriate. --------------------------------- User settable variables set PlaylistName to "AAA" -- Just add the tracks you want to change to a single playlist. When dione, delete the playlist. set trimInitialchars to 0 -- nonzero value takes precedence over any addstart value set trimFinalchars to 0 set addstart to "" -- nonempty value wil overide addend set addend to "" --------------------------------- End of user settable variables set trimstart to trimInitialchars + 1 tell application "iTunes" activate set tracklst to every track of playlist PlaylistName set trackcount to number of items in tracklst repeat with n from 1 to trackcount -- Do the whole playlist: set oldtitle to name of track named (name of item n of tracklst) if trimInitialchars is greater than 0 then -- Trim stuff from front of track names set name of (item n of tracklst) to (characters trimstart through length of oldtitle) as text else if trimFinalchars is greater than 0 then -- Trim stuff from front of track names set name of (item n of tracklst) to (characters 1 through ((length of oldtitle) - trimFinalchars) of oldtitle) as text else if addstart is not "" then -- Add something to front of track names set name of (item n of tracklst) to (addstart & oldtitle) else if addend is not "" then -- Add something to end of track names set name of (item n of tracklst) to (oldtitle & addend) end if end repeat end tell