Text File List of Songs Search iTunes, Copy then Save to a folder?

Hey guys,

I spent over 2 hours going through every applescript of Doug’s Applescripts to try to find a script that will allow me to select a text file that has names of songs, which will then search my entire iTunes for those songs, copy them and put them in a folder on my desktop.

Anybody have a clue how to do this?

Thanks for your time.

Phil

Hi there,

assuming your text file is just a list of song names without the file extension i.e.

Bombtrack
Killing In The Name
Take The Power Back
Settle For Nothing
Bullet In The Head
Know Your Enemy
Wake Up
Fistful Of Steel
Township Rebellion
Freedom

Then the script below should do what you’re after.

set tracksToFindList to every paragraph of (do shell script "cat " & quoted form of POSIX path of (choose file with prompt "Choose your track list text file"))
set destFolder to POSIX path of ((path to desktop as string) & "Copied_iTunes_Tracks")
my folderCheck(destFolder)

tell application "iTunes"
	set iTunesTracksList to name of every track
	repeat with trackToFind in tracksToFindList
		if trackToFind is in iTunesTracksList then
			set foundTrack to item 1 of (every track whose name is trackToFind)
			set trackPath to location of foundTrack
			my copyTrack(destFolder, trackPath)
		end if
	end repeat
end tell

on folderCheck(theFolder)
	set folderStatus to do shell script "if [ -d " & quoted form of theFolder & " ]; then echo true;else echo false; fi;" --> check a directory exists
	if folderStatus is "false" then do shell script (do shell script "mkdir -m 777 " & quoted form of theFolder)
end folderCheck

on copyTrack(destFolder, trackPath)
	set filename to do shell script "basename " & quoted form of POSIX path of trackPath
	do shell script "cp " & quoted form of POSIX path of trackPath & space & quoted form of (destFolder & "/" & filename)
end copyTrack

Hope this helps,
Nik

Nik,

Thanks a lot. It worked perfectly.

That was how I had my list!

Thanks again.

Phil