The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Applications (http://hintsforums.macworld.com/forumdisplay.php?f=5)
-   -   Creating CDs/DVDs for vehicles - must be a better way (http://hintsforums.macworld.com/showthread.php?t=104288)

onceagain 08-14-2009 01:12 PM

Quote:

Originally Posted by anika123 (Post 546947)
Can I get a quick pointer on how to create a plist file please. I would like to try this script.

Sure.

1). Open "/Developer/Applications/Utilities/Property List Editor"

2). In the window that comes up, click on the "Root" element and then hit the "Add Child" button 5 times, to add 5 items.

3). Now, go through and rename all of the items from "New item..." to one of the item names needed. These are: scriptFile, sourceDir, fileLimit, fileExtension, and dirPrefix.

4). Next, change the Type for fileLimit to Number (the rest stay as String).

5). Now, assign the values you want to use. In my case, I am using the following:

scriptFile - movetracks.sh
sourceDir - songs
fileLimit - 100
fileExtension - .mp3
dirPrefix - music_

6). Finally, save the file in ~/Library/Preferences/trackmover.plist

That's it.

If you do not happen to have the Developer tools installed, you will need to manually create a file, using any text editor, that looks something like this:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>fileLimit</key>
        <integer>100</integer>
        <key>scriptFile</key>
        <string>movetracks.sh</string>
        <key>dirPrefix</key>
        <string>music_</string>
        <key>fileExtension</key>
        <string>.mp3</string>
        <key>sourceDir</key>
        <string>songs</string>
</dict>
</plist>

A plist that has the values I am using requires your source directory (the one with all the tracks) to be named "songs" and will generate a directory structure that looks like "music_001 music_002 music_003....music_010" (assuming 1000 songs as input).

Also, regrarding point "d" in my previous post. You do NOT need to have the program in the same directory as the source directory, you only need to be in that directory when you run the program from the command line. Alternatively, you could specify a full path in the plist file, then you could be anywhere. If you specify a full path for the output directory prefix, then it would be even more flexible.

FWIW, I installed this program in /usr/bin/local/trackmover.pl and made a link (ln -s) to /usr/bin/local/trackmover - so now I can run execute it by running "trackmover" from the command prompt, from anywhere.

tw 08-14-2009 07:10 PM

sorry for coming to this discussion late, but that seems like an UGLY mess of code. why not simply do this: set up your playlist in iTunes (using the shuffle option as needed to get a randomized selection), write an applescript that runs through the shuffled playlist and does the following:
  • creates a burn folder on the desktop
  • creates a folder for each 100 tracks in the burn folder
  • creates 100 folders in each 100-track folder (with sequential names for the folders, so they'll stay in order)
  • writes an alias for each track into each folder
no need to mess with changing file names or anything like that, no need for extra disks or lots of file copying... give me a few minutes and I'll work up a draft.

onceagain 08-14-2009 07:34 PM

Quote:

Originally Posted by tw (Post 547052)
sorry for coming to this discussion late, but that seems like an UGLY mess of code.

Thanks.

Quote:

why not simply do this: set up your playlist in iTunes (using the shuffle option as needed to get a randomized selection), write an applescript that runs through the shuffled playlist and does the following....
Because I don't know applescript.....and I avoid vendor-specific solutions whenever possible anyway.

Quote:

[list][*]creates a burn folder on the desktop[*]creates a folder for each 100 tracks in the burn folder[*]creates 100 folders in each 100-track folder (with sequential names for the folders, so they'll stay in order)[*]writes an alias for each track into each folder
Sounds like you're talking about burning a disc with sub-sub directories - which the player in my Jeep doesn't recognize (I know, because I've tried).

tw 08-14-2009 07:53 PM

Quote:

Originally Posted by onceagain (Post 547056)
Because I don't know applescript.....and I avoid vendor-specific solutions whenever possible anyway.

suit yourself. :)

anika123 08-14-2009 08:04 PM

umm, I would like to see the "draft". :)

tw 08-14-2009 08:45 PM

Quote:

Originally Posted by anika123 (Post 547059)
umm, I would like to see the "draft". :)

eh, I was going to post it anyway. :-) this version doesn't use the sub-sub folders (since those seem to be objectionable), and it doesn't change the file name (just appends an index on the front of the alias file - might cause some problems if the file name is too long, since that might erase the file extensions on the DVD - but one thing at a time)
Code:

property burnFolderPath : (path to desktop as text) & "Burn Me"

tell application "iTunes"
        set {theNames, theFilePaths} to {name, location} of (every file track of playlist "new")
end tell
tell application "Finder"
        try
                set burnFolder to make new folder at desktop with properties {name:"Burn Me.fpbf"}
                set extension hidden of burnFolder to true
        on error
                set burnFolder to folder ((desktop as text) & "Burn Me")
                delete (every item of burnFolder)
        end try
        set idxFile to 0
        set idxFolder to 1
        repeat with i from 1 to count theFilePaths
                if (i - 1) mod 100 is equal to 0 then
                        set folderName to ("F_" & characters -3 thru -1 of ("000" & idxFolder)) as text
                        set theFolder to make new folder at burnFolder with properties {name:folderName}
                        set idxFolder to idxFolder + 1
                end if
                set filePath to item i of theFilePaths
                set ext to name extension of file (filePath as text)
                set cleanedName to my cleanName(item i of theNames)
                set fileName to ("f" & (characters -3 thru -1 of ("000" & i)) & "_" & cleanedName) as text
                set newAlias to make new alias file at theFolder to filePath
                set name of newAlias to fileName
        end repeat
end tell

to cleanName(txt)
        repeat with delim in {":", "/", "\\"}
                set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, delim}
                set temp to text items of txt
                set AppleScript's text item delimiters to "_"
                set txt to temp as text
                set AppleScript's text item delimiters to tid
        end repeat
        return txt
end cleanName


onceagain 08-14-2009 09:11 PM

Looks nice - you've got the idea anyway.

Unfortunately, if you burn that folder "burn me" with Toast, all you get are the aliases, rather than the real files that will play in the Jeep (Toast warn about the .mp3 extensions, by the way).

tw 08-14-2009 09:29 PM

errr... the reason it's called a 'burn folder' is that you can just click the burn button in the folder itself, and the system will do it for you. no toast needed (unless you're hungry). admittedly, I've never tried to use a burn folder to burn a DVD, but there's kinks in every plan.

onceagain 08-14-2009 10:29 PM

Quote:

Originally Posted by tw (Post 547075)
errr... the reason it's called a 'burn folder' is that you can just click the burn button in the folder itself, and the system will do it for you. no toast needed (unless you're hungry). admittedly, I've never tried to use a burn folder to burn a DVD, but there's kinks in every plan.

I see. I've never used anything other than Toast for burning discs (other than the one time I used iTunes, as described in post #1). In any case, after running your script, I don't see anything that could be described as a "burn button" - just 12 subdirectories of various names.

tw 08-14-2009 10:41 PM

ah, yeah... I got tricky and it snarked on me. use these lines instead, at the obvious places:
Code:

property burnFolderPath : (path to desktop as text) & "Burn Me.fpbf"

set burnFolder to make new folder at desktop with properties {name:"Burn Me.fpbf"}


onceagain 08-15-2009 03:07 AM

Yep. That looks like a solution. I didn't actually burn it, but it was asking me for a disc, and said I needed 8GB or so. I'm assuming that if I followed through it it, it would make something that would actually work in the Jeep.

On a related note - I never heard of a burn folder before. Now, having had them pointed out to me, I can see an option for it as plain as day in the Finder's File menu. Go figure.

tw 08-15-2009 01:18 PM

Quote:

Originally Posted by onceagain (Post 547087)
On a related note - I never heard of a burn folder before. Now, having had them pointed out to me, I can see an option for it as plain as day in the Finder's File menu. Go figure.

yeah, it's weird. they introduced those all the way back in the first version of Tiger, I think, and then everyone promptly forgot about them (maybe because there were so many other options). but for quick, basic burning needs they are pretty useful.

onceagain 08-15-2009 05:15 PM

Quote:

Originally Posted by tw (Post 547108)
yeah, it's weird. they introduced those all the way back in the first version of Tiger, I think, and then everyone promptly forgot about them (maybe because there were so many other options). but for quick, basic burning needs they are pretty useful.

For the first 2 years of owning my Jeep, I would periodically find a new button or knob that I never noticed before.


All times are GMT -5. The time now is 12:01 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.