Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > help with itunes/finder applescript

help with itunes/finder applescript
Thread Tools
Senior User
Join Date: Mar 2001
Status: Offline
Reply With Quote
Feb 3, 2002, 12:59 PM
 
hello, can anyone help me with an easy way to add to the path of a file in itunes. I know how to get the path and filename (location of) and even create a new directory in the existing directory. But how then can I move the file into that new directory?

I'm kinda new to applescript and the "natural language" scripting still seems a little counterintuitive to me.

Thanks!
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Feb 4, 2002, 09:37 AM
 
Originally posted by iamnotmad:
<STRONG>hello, can anyone help me with an easy way to add to the path of a file in itunes. I know how to get the path and filename (location of) and even create a new directory in the existing directory. But how then can I move the file into that new directory?

I'm kinda new to applescript and the "natural language" scripting still seems a little counterintuitive to me.

Thanks!</STRONG>
Your message is kind of confusing. Add? You mean like:

get "Mac HD:Documents:MP3s:" & "newFolder:file.mp3"

?

[ 02-04-2002: Message edited by: Synotic ]
     
Senior User
Join Date: Mar 2001
Status: Offline
Reply With Quote
Feb 4, 2002, 10:59 AM
 
Originally posted by Synotic:
<STRONG>Your message is kind of confusing. Add? You mean like:

get "Mac HD:Documents:MP3s:" & "newFolder:file.mp3"

?

[ 02-04-2002: Message edited by: Synotic ]</STRONG>
Yeah, sorry, I was tired when I posted that. But your assumption is essentially correct.

I am using "set foo to location of track" essentially. But that returns the path and filename. So I cannot simply concatinate more path on there. Do I have to parse it to separate out the path? that seems anti-applescript, is there a way to just get the path that I can add to?

Thanks. (thanks for responding)
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Feb 4, 2002, 01:06 PM
 
Originally posted by iamnotmad:
<STRONG>

Yeah, sorry, I was tired when I posted that. But your assumption is essentially correct.

I am using "set foo to location of track" essentially. But that returns the path and filename. So I cannot simply concatinate more path on there. Do I have to parse it to separate out the path? that seems anti-applescript, is there a way to just get the path that I can add to?

Thanks. (thanks for responding)</STRONG>
The path is meant to include the name of the file/folder/package. Unfortunately the only way that I can think of is to parse out the last part. Here is what you need...

tell application "iTunes" to set thePath to (location of track 1 of playlist 1) as string
set AppleScript's text item delimiters to ":"
set thePath to items 1 through -2 of (every text item of thePath)
set thePath to (thePath as string) & ":"
set AppleScript's text item delimiters to {""}

get thePath & "new folder:file.mp3"


Basically what this does is change the delimiter to a ":" then it splits up the path into a list. Now it'll look like {"Mac HD", "Docs", "MP3s", "file.mp3"} then I get items 1 through -2, negative numbers go backwards, so I'll get all the items but the file name. Then I turn it back into a string using ":" and then I add an additional ":" to show that it is a folder, and then I append the additional info.

--chris
     
Senior User
Join Date: Mar 2001
Status: Offline
Reply With Quote
Feb 5, 2002, 01:26 AM
 
Originally posted by Synotic:
<STRONG>The path is meant to include the name of the file/folder/package. Unfortunately the only way that I can think of is to parse out the last part. Here is what you need...

tell application "iTunes" to set thePath to (location of track 1 of playlist 1) as string
set AppleScript's text item delimiters to ":"
set thePath to items 1 through -2 of (every text item of thePath)
set thePath to (thePath as string) & ":"
set AppleScript's text item delimiters to {""}

get thePath & "new folder:file.mp3"


Basically what this does is change the delimiter to a ":" then it splits up the path into a list. Now it'll look like {"Mac HD", "Docs", "MP3s", "file.mp3"} then I get items 1 through -2, negative numbers go backwards, so I'll get all the items but the file name. Then I turn it back into a string using ":" and then I add an additional ":" to show that it is a folder, and then I append the additional info.

--chris</STRONG>
Ok, so looks like parsing the return value is it. That's a shame, they should separate "filename" from "path" that would be much more easily flexible. Thanks again.
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Feb 5, 2002, 05:31 AM
 
Originally posted by iamnotmad:
<STRONG>Ok, so looks like parsing the return value is it. That's a shame, they should separate "filename" from "path" that would be much more easily flexible. Thanks again.</STRONG>
The path name is supposed to have the name of the file in it. If it returned something like {"path ath ath:", "file.mp3"} then whenever you want to use it as a normal path (99% of the time) then you would have to add "as string" to the end.

But what if {"path ath ath:", "file.mp3"} was the format for a path? Well then if you ever need to generate your own path, or get a path from a user, then you'll have to parse it into list form.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:37 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2