tzikeh: (question - inquiry - bafflement)
[personal profile] tzikeh

ETA: [livejournal.com profile] halcyon_shift IS A GENIUS! I'm running out the door for the day, but when I get back, I'll post a simple explanation of how to do this for folks unfamiliar with creating/running AppleScript.

YAY!!!

So.

I am trying to burn a playlist from iTunes (Mac OS X 10.5.6, iTunes 8.1.1 (10)), and no matter how I try to burn it, either directly in iTunes, or dragging to a DVD image and choosing "burn disc", or using Toast, it reorders the playlist alphabetically by song title. I have tried everything to get it to burn in the order I've put it in.

I found this nifty Automator script, that *looks* like it should work.
It looks like this:

1. Automator » Ask for Confirmation (This may be Leopard only.). This asks if the user wishes to continue, since it may take a while to run.

2. iTunes » Get Selected iTunes Items. This will select all songs that you've selected in iTunes, such as the songs in a playlist.

3. Finder » Copy Finder Items. This will copy the song files to the Finder. Select a default folder, such as the Desktop. Check the "Show This Action When the Workflow Runs" box under Options to allow you to choose a folder to export a particular playlist into.

4. Finder » Rename Finder Items (Make Finder Item Names Sequential). You should say Make Sequential in the top drop-down, and then select Add number to existing item name. Select Place number before name, Start numbers at 1, separated by dash (or underscore, etc), and make all numbers X digits long. X should be 1 to 3, depending on how many songs you have -- three digits will allow you to export more than 100 songs.

5. Save your workflow to the scripts folder, or as an application to add to your Dock.

When run, the workflow will first copy the files to the selected Finder folder, then rename them. You can then burn the folder -- and any other folders of exported playlists -- to a disc, using the Finder or Toast. Problem solved!

********

I set it up exactly as it's listed here. I went into iTunes, clicked on my playlist, and selected the tracks. When the script runs, "Get Selected Items" gives conflicting messages. On one hand, it takes no time at all to import the 116 mp3 files I have selected in my playlist, and they show up in the results window for "Get Selected Items". Yet at the same time, in the Log window, the yellow warning triangle appears and says "The action "Get Selected Items" was not supplied with the required data". Directly under that in the log, it says "Get Selected Items completed," with a green checkmark next to it. Meanwhile, it only took 67 seconds to "Get Selected Items" with its green checkmark, and "Converting iTunes items" is the one with the grey circle with the arrow in it (indicating it's currently running), yet the progress bar at the bottom of the Automator window still say "Get Selected Items" and the circle of gray bars is still spinning, twenty minutes later.

So then, I asked on the Apple discussion forums, both under Automator and iTunes, and someone had written an AppleScript to do exactly what the Automator script was supposed to do. Someone else had replied to that post saying it worked brilliantly, so I tried it too.



I'm using dashes to show the beginning and end of the script; obviously they are not *part* of the script.

-----------------------------------------------

(* copy and rename iTunes items *)

if application "iTunes" is not running then
display alert "iTunes is not running" message "Please activate iTunes and select items."
return
end if

-- set up a few things
choose folder with prompt "Choose a folder to copy the selected iTunes items into:" default location (path to desktop)
set DestinationFolder to the result
set {PrefixNumber, TrackLocations} to {0, {}}

-- get filepaths of the selected iTunes items
tell application "iTunes" to repeat with SomeTrack in (get the selection)
try -- skip items that are not file tracks (no location)
set the end of TrackLocations to location of SomeTrack
end try
end repeat

-- copy and rename
repeat with SomeFile in TrackLocations
set PrefixNumber to text 2 thru -1 of ((1000 + PrefixNumber + 1) as text) -- prefix with leading zeros
tell application "Finder"
set NewName to PrefixNumber & "-" & (get name of SomeFile)
set the name of (duplicate SomeFile to DestinationFolder) to NewName
end tell
end repeat

tell application "Finder" to reveal DestinationFolder

-----------------------------------------------

I have a feeling that the reason it doesn't work is that there are variables in here that I'm supposed to change to names of files and folders on my computer, but I don't know which they are.

Can anyone help?

Date: 2009-04-18 04:42 am (UTC)
From: [identity profile] brivinex.livejournal.com
You probly already know this and have a completely different problem, but maybe this'll help. If you accidentally made iTunes sort everything alphabetically on a play list you just click the little arrow at the top left of the play list right above the first song, and it'll go back how you ordered it.

Picture to help.
http://farm4.static.flickr.com/3372/3451229497_de8f6185ff.jpg?v=0

hopefully that's helpful. I know it took me forever to figure it out.

Date: 2009-04-18 04:45 am (UTC)
From: [identity profile] tzikeh.livejournal.com
Alas, no - that's not the problem. I know about that just fine, but it only works *in the playlist window*. And the tracks are already in the order I like in the playlist window. It's once I try to move them to be burned that it goes all alphabetical.

Date: 2009-04-18 05:24 am (UTC)
From: [identity profile] loreleif.livejournal.com
I'm tired, so I could be missing something (I'll keep this open and look again tomorrow), but it looks okay at first glance. One problem I know I've had - is your music by any chance stored on a drive other than your startup, like an external hard drive? Often scripts don't seem to like that.

Date: 2009-04-18 05:28 am (UTC)
From: [identity profile] tzikeh.livejournal.com
Oh, man, it *is* stored on an external drive. Is that going to entirely fuck it up??

Dammit.

Date: 2009-04-18 05:32 am (UTC)
From: [identity profile] loreleif.livejournal.com
It won't fuck anything up, don't worry - it just won't work. Something in the way the path works doesn't let it see the files the same as it would usually. I usually move the files temporarily, then move them back. There may be a better solution, though; lemme check.

Date: 2009-04-18 05:36 am (UTC)
From: [identity profile] tzikeh.livejournal.com
Moving 30,000 mp3s is not going to be quick. ;)

Date: 2009-04-18 05:41 am (UTC)
From: [identity profile] loreleif.livejournal.com
Um, no. LOL Didn't realise you were doing this for that many. Did find a solution, though! Check it out here (http://forums.macrumors.com/showthread.php?t=596568); you can see an explanation of the problem, too.

Hm. So, looks like we need to get the POSIX path of each item. I'll play with it tomorrow, see if I can get it to work.

Date: 2009-04-18 05:43 am (UTC)
From: [identity profile] tzikeh.livejournal.com
OH! No no, the playlist is only 116 tracks. I just thought you meant we'd have to move all of my music in order for it to work.

But thank you for taking the time to look at it tomorrow!

Date: 2009-04-18 06:19 am (UTC)
From: [identity profile] gwyn-r.livejournal.com
Man, I wish I understood any of this, because I have the same problem and it drives me utterly batshit, and for that reason I rarely burn anything, even though I want to.

Date: 2009-04-18 09:44 am (UTC)
ext_8855: (Default)
From: [identity profile] halcyon-shift.livejournal.com
I haven't done any AppleScript before so, you know. Warning ;) I ran this, it copies into a folder on the desk top and does strange things to the name - I don't know what you actually want the name to be so I didn't touch that. If you wanted something specific, let me know and I'll see what I can prod with stick.

1) Open iTunes
2) Select music
3) Run script

-----

tell application "System Events" to set open_applications to ("iTunes")

choose folder with prompt "Choose a folder to copy the selected iTunes items into:" default location (path to desktop)
set DestinationFolder to the result
set {PrefixNumber, TrackLocations} to {0, {}}

tell application "iTunes" to repeat with SomeTrack in (get the selection)
try
set the end of TrackLocations to location of SomeTrack
end try
end repeat

repeat with SomeFile in TrackLocations
set PrefixNumber to text 2 thru -1 of ((1000 + PrefixNumber + 1) as text)
tell application "Finder"
set NewName to PrefixNumber & "-" & (get name of SomeFile)
set the name of (duplicate SomeFile to DestinationFolder) to NewName
end tell
end repeat

tell application "Finder" to reveal DestinationFolder

----

Date: 2009-04-18 02:57 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
Okay, what I want it to do is put a prefix number before the name of each track in the playlist (001_name, 002_name, etc.) so that when I try to burn the tracks and it orders them, it will order them properly as I've set them, and not in alpha order.

What is all of this "SomeTrack" and (get the selection) -- should I be renaming them things specific to my computer?

Date: 2009-04-18 03:03 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
OH MY GOD IT WORKED. It didn't at first, but once I saved it to the external drive where iTunes is, it TOTALLY WORKED.

*I KISS YOU*

omg omg omg

Date: 2009-04-18 03:07 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
DUDE [livejournal.com profile] halycon_shift FIGURED IT OUT.

I have to run, but when I get back I'll tell you how to implement the script and you will be JOYOUS!

Date: 2009-04-18 03:08 pm (UTC)
ext_8855: (Default)
From: [identity profile] halcyon-shift.livejournal.com
I was about to reply saying it should work, and now I don't have to. Awesome! *g* Welcome! :)

Date: 2009-04-18 03:09 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
OMG [livejournal.com profile] halcyon_shift wrote a kinda tweaked script and it worked! It didn't at first, but when I saved the script to the external drive where iTunes library is stored, it worked brilliantly!

Date: 2009-04-18 03:12 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
What did you change?!

Date: 2009-04-18 03:16 pm (UTC)
ext_8855: (Default)
From: [identity profile] halcyon-shift.livejournal.com
Very little :)

I replaced
if application "iTunes" is not running then
display alert "iTunes is not running" message "Please activate iTunes and select items."
return
end if


with
tell application "System Events" to set open_applications to ("iTunes")

I think it's entirely possible you could just lose that line altogether and just make sure you have iTunes open before running the script, but I haven't tested that

Date: 2009-04-18 03:22 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
So... the whole script the guy wrote should have worked, if he'd remembered to tell me "oh, by the way, make sure it's saved to the same drive your iTunes library is on"?

BAH.

Date: 2009-04-18 03:26 pm (UTC)
ext_8855: (Default)
From: [identity profile] halcyon-shift.livejournal.com
That and taken out the part I replaced - it was erroring out on my system

Date: 2009-04-18 03:27 pm (UTC)
From: [identity profile] loreleif.livejournal.com
D'oh! And I just got one working, too. Ah, well. Here you go, just in case. I had it get the whole path of the files, then copy them, *then* rename them. (Doesn't matter where the script or copies are saved, so at least I accomplished something different, right? :) )

(* copy and rename iTunes items *)

if application "iTunes" is not running then
display alert "iTunes is not running" message "Please activate iTunes and select items."
return
end if

-- set up a few things
choose folder with prompt "Choose a folder to copy the selected iTunes items into:" default location (path to desktop)
set DestinationFolder to the result
set {PrefixNumber, TrackLocations} to {0, {}}

-- get filepaths of the selected iTunes items

tell application "iTunes" to repeat with SomeTrack in (get the selection)
try -- skip items that are not file tracks (no location)
set the end of TrackLocations to (the location of SomeTrack as string)
end try
end repeat


-- copy and rename
repeat with SomeFile in TrackLocations
set PrefixNumber to text 2 thru -1 of ((1000 + PrefixNumber + 1) as text) -- prefix with leading zeros
tell application "Finder"

set NewFile to (duplicate SomeFile to DestinationFolder)
set NewName to PrefixNumber & "-" & (the name of NewFile)
set the name of NewFile to NewName

end tell
end repeat

tell application "Finder" to reveal DestinationFolder

(Edited to post without a line specific to my computer which wasn't necessary anyway. And now I'm going to breakfast.)
Edited Date: 2009-04-18 03:29 pm (UTC)

Profile

tzikeh: (Default)
tzikeh

August 2022

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930 31   

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 26th, 2026 11:40 pm
Powered by Dreamwidth Studios