 |
 |
help with itunes/finder applescript
|
 |
|
 |
|
Senior User
Join Date: Mar 2001
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|