3
votes

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 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?

2

2 Answers

3
votes

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
1
votes

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