Change file path in iTunes using AppleScript

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

The overall flow will be something like this:

  • Get a Choice
  • Determine the path to the choice
  • Move items to destination
  • Update Link Path in iTunes

I used the sentence of this question to get the path to the selection in iTunes, and I can figure out how to move the files to where I want them, however, now I want to tell iTunes that the path to the file is actually in a different place.

Does anyone know how to do this?

+4
source share
2 answers

I get it. I had another mistake that made me think it was harder than it is. Here's how I earned it:

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 
+4
source

The basic idea is to set the location property for each file track element to its new file path. For instance:

 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 
+1
source

Source: https://habr.com/ru/post/1315001/


All Articles