PDA

View Full Version : Bit of help creating an applescript for itunes..?




nick0831
Mar 10, 2008, 07:35 PM
Hi Everyone. I'm new, so bear with me.

I have a central file store with all my tunes on. It's a PC server. I can access all the songs from my Powerbook as I have set the library to point to my main store on the PC.

I copied the .itl file from the server pc to the mac and had to choose 'hide extension' so that the filename was the same on the PC and mac. Straight away, when I opened Itunes, everything was there as it should be, reading from the server!

Now, what I want to do, is create an applescript that updates the .itl file from the server to my mac every time I restart it. I'm not very hot with applescript, but essentially, I need it to do the following:

take file from server
hide extension *.itl
replace it with file on my mac

Can someone please help me out?!

Thanks so much, and a big hello!



allbrokeup
Mar 11, 2008, 06:05 AM
Try This:

Get File;

tell application "Finder"
of machine (PC) "eppc://Username:Password@the.ip.address.here"
duplicate "/Documents And Settings/-USERNAME-/PATH/TO/.ITL/FILE/" to "/Users/-USERNAME-/Music/iTunes/" of machine "eppc://Username:Password@The.IP.Address.Here".

That should get you at least one step of the way.
(Updated to be smoother and a LOT quicker to understand :D:D)
allbrokeup.

nick0831
Mar 11, 2008, 05:00 PM
many thanks for this. I will give it a go.

thanks again!

Any more help, much appreciated.

Nick

cpjakes
Mar 11, 2008, 05:49 PM
Maybe other people know better if this works, but can't you just make an alias of the file so there's only one file?

I would think that with the AppleScript version, you would still need to automount the PC if you weren't already...

cpjakes

allbrokeup
Mar 12, 2008, 03:19 AM
Toggle File Extensions On/Off:

on open files_
repeat with file_ in files_
tell application "Finder"
try
if extension hidden of file_ is true then
set extension hidden of file_ to false
else
set extension hidden of file_ to true
end if
duplicate file_ to "Macintosh HD:Users:USERNAME:Music:iTunes:"
on error e
display dialog e buttons {"OK"} default button 1
end try
end tell
end repeat

end open

Paste that into Script Editor or Xcode AppleScript App's Script. It will become a droplet. Simply drag a file onto the Icon and it will Hide the Extension if its showing and vice-versa, also Copy the Dropped Library to the iTunes Music Folder on Mac OS X. Write all other code in the 'On Open' Handler, such as my 'of machine' code. In my other hint, leave out the (PC) and the (MAC) as it was just a guide to show what IP Address to include first. Also please make sure that the PC is connected to your Network or the code I included before won't work.

Instructions:
Put the 'Of Machine' code in the On Open handler but use:


allbrokeup.

motulist
Mar 12, 2008, 03:33 AM
Just make an automator workflow. It's super easy, you open automator, hit the record button, and it records all your mouse and keyboard moves. You usually have to tweak it a little after making the recording, but imo making an automator workflow is MUCH easier than making an applescript. At this point applescript is only for things that really require the extra power of applescript, and soon enough automator will probably be capable enough to replace applescript anyway.

nick0831
Mar 13, 2008, 07:29 AM
Toggle File Extensions On/Off:

on open files_
repeat with file_ in files_
tell application "Finder"
try
if extension hidden of file_ is true then
set extension hidden of file_ to false
else
set extension hidden of file_ to true
end if
duplicate file_ to "Macintosh HD:Users:USERNAME:Music:iTunes:"
on error e
display dialog e buttons {"OK"} default button 1
end try
end tell
end repeat

end open

Paste that into Script Editor or Xcode AppleScript App's Script. It will become a droplet. Simply drag a file onto the Icon and it will Hide the Extension if its showing and vice-versa, also Copy the Dropped Library to the iTunes Music Folder on Mac OS X. Write all other code in the 'On Open' Handler, such as my 'of machine' code. In my other hint, leave out the (PC) and the (MAC) as it was just a guide to show what IP Address to include first. Also please make sure that the PC is connected to your Network or the code I included before won't work.

Instructions:
Put the 'Of Machine' code in the On Open handler but use:


allbrokeup.

Wow! Thanks so much. That's great. Thanks very much EVERYONE who's contributed to this thread. I REALLY appreciate all your help. What a great forum.

allbrokeup
Mar 16, 2008, 02:15 AM
glad you like this place :D. Did my code work OK? I actually had to employ that but to copy it from my Mac HD to a Windows PC, it worked. I hope it worked for you, I really do. :D

On another sort of topic, I have created a big AppleScript App that customizes the Mac OS X Dock, that enables or disables hacks according to system version (notably Leopard and Tiger). Does anyone know where I can upload it for download on the Web for free? or here for that matter? Any help would be great. Beta release is on Google Code 'http://code.google.com/dock'

thanks, and I dont mean to make this about me. really hope my hint worked for Nick.

allbrokeup.