Code/new Copy Singers
So with the advent of "Venues" you may have run into the situation where a singer from another venue shows up out of the blue at the current venue, wanting to see their history list. Accessing it is kinda a nightmare, involving going to the Finder, drilling down until you find the right singer folder, creating an alias, and then copying that alias over to the current venue folder, followed by changing venues in kJams, and then changing it back again in order to force kJams to reload the current venue's Singers folder.
Well, I can't do anything about the kJams end of things, as that functionality is not currently exposed to an API like Applescript, but what I can do is automate the rest. After a full 1/2 day of work (mostly since I am a lousy programmer!) I managed to get the following working. You have two choices on how to use this. You can open Applescript Editor and paste the following code into a new script window, and save as an application, and then run as you would any other application. But better yet, open up Automator, select "Service" from the template choices on the opening splash screen, and then drag "Run AppleScript" from the Library onto the Stage. Change the "Service receives selected" popup to "no input", and "applications" to "kJams". (First choose "other…" from the popup menu, and then browse to kJams in the file selector.) Next, paste the following code over top of where is says (* Your script goes here *) and save.
Then when you run kJams, and need this functionality, either run the application from where you saved it to, or if you saved it in automator as a service, simple select "Services" from the kJams menu, and then select your saved service. At that point just follow the prompts to tell the service which singers you want to transfer (you can transfer multiple singers at the same time.) This will put an alias in your current venue folder, thus letting that singer access his or her playlists from either venue.
Hope this is helpful.
set kJamsPath to "Users/u-chunchoi/Music/kJams/kJams Library/"
set kJamsLibraryPath to kJamsPath & "Library.xml"
set XMLfile to (POSIX file (kJamsLibraryPath))
set Paras to paragraphs of (read XMLfile)
-- we parse the XML file and extract the portion between the tags we're interested in
-- we know that the tag we want is immediately after "<key>Current Value</key>"
set tagValue to {}
repeat with i from 1 to count of Paras
if item i of Paras contains "Current Venue" then -- first we find the tag we're interested in
set tagValue to item (i + 1) of Paras
exit repeat
end if
end repeat
-- return tagValue
-- next we extract each value from the found tags knowing that the value is between "<string>" and "</string>
repeat with i from 1 to count of tagValue
set thisTag to item i of tagValue
set thisTagValue to ""
if thisTag is ">" then
repeat with k from (i + 1) to count of tagValue
set thisTag to item k of tagValue
if thisTag is "<" then exit repeat
set thisTagValue to thisTagValue & thisTag
end repeat
exit repeat
end if
end repeat
thisTagValue
set kJamsPath to kJamsPath & "Venues/"
set venuePath to (POSIX file (kJamsPath))
set singerPath to (POSIX file (kJamsPath & thisTagValue & "/Singers"))
set Singers to (choose folder default location alias venuePath with prompt "Choose singers to copy to the current venue" with multiple selections allowed) as list
repeat with i from 1 to count of Singers
tell application "Finder"
set Singer to item i of Singers
make new alias file at singerPath to Singer
end tell
end repeat