Hi, I would like to have applescript take the track, take the name of the track (The Beatles - Hey Jude) and delete “The Beatles” only… So it would be Hey Jude only in the title column. The Beatles is already in the artist column. I would like to know how to structure a script so that I may do this for a list of songs.
Any Help is very appreciated so I may learn more about Applescript.
Model: MacBook
AppleScript: 2.1.1
Browser: Safari 523.12
Operating System: Mac OS X (10.4)
There cud be an easier way and this only works if the artist name is filled out. So say the track name is “The Beatles - Hey Jude” the artist still has to be filled in as “The Beatles”
tell application "iTunes"
set curtrack to the current track
set theSong to the name of curtrack
set theArtist to the artist of curtrack
end tell
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {theArtist & " - "}
set theSong to text items of theSong
set AppleScript's text item delimiters to {""}
set theSong to theSong as Unicode text
set AppleScript's text item delimiters to {""}
set theSong to theSong as string
tell application "iTunes"
set name of curtrack to theSong
end tell
Here is another solution. It will rename whatever you have selected
as long as the name has two parts separated by " - " as in your example.
Regards,
Craig
tell application "iTunes"
set theSel to selection
repeat with i from 1 to count of theSel
set thisTrack to item i of theSel
set theSong to the name of thisTrack
set name of thisTrack to item 2 of my tidStuff(" - ", theSong)
end repeat
end tell
on tidStuff(paramHere, textHere)
set OLDtid to AppleScript's text item delimiters
set AppleScript's text item delimiters to paramHere
set theItems to text items of textHere
set AppleScript's text item delimiters to OLDtid
return theItems
end tidStuff
nice, but you’d have to be careful because some songs are hyphenated on purpose. Then again you did it for the selected track so you might not have to worry about that.
Ah, I appreciate the fast replies, but it is separated by not just 1 hyphen but a few.
Example ( Empires - 09 - Darkangel )
The artist field is already filled out (VNV Nation) but the album is “Empires”, the track number is “09” and the title of the song is “Darkangel”.
The scripts provided separate the standard form of the track info being “VNV Nation - Darkangel” but is there a way to put “Empires” as the album, the track name as “09” and the title as “Darkanglel”?
Thanks,
Chris
Model: MacBook
AppleScript: 2.1.1
Browser: Safari 523.12
Operating System: Mac OS X (10.4)
ok so the track number and album aren’t filled out at all? just the artist?
im a little confused to your needs
Hi,
this takes always the part after the last hyphen
tell application "iTunes"
set theSel to selection
set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, " - "}
repeat with oneTrack in theSel
set theSong to the name of oneTrack
if theSong contains " - " then
set name of contents of oneTrack to last text item of theSong
end if
end repeat
set AppleScript's text item delimiters to ASTID
end tell