开发者

Changing the path to a file in iTunes with AppleScript

I am trying to write an iTunes script that takes the selected tracks, moves the files to a different folder on my hard drive, and then update their location in iTunes.

The overall flow will be something like this:

  1. Get selection
  2. Determine path to selection
  3. Move items to destination
  4. Update referenced path in iTunes

I used the suggestion from this question to get the path of a selection in iTunes, and I will be able开发者_JAVA技巧 to figure out how to move the files to where I want them, however, now I want to tell iTunes that the file path is actually some place else.

Anybody know how to go about this?


I figured it out. I had a different error that was making me think this is harder then it is. Here's how I got it to work:

  tell application "iTunes"
     set s to selection
        repeat with c in s
           if video kind of c is TV show then
              set location of c to <destination directory>
              <code to move file>
           end if
  end tell


The basic idea is to set the location property of each file track item to its new file path. For example:

tell application "iTunes"
    tell its first browser window
        set currentTrack to first item of (get its selection)
        set location of currentTrack to POSIX file "/Users/nad/Music/movedfile.m4a"
    end tell
end tell
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜