Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'd like to write a script which will move watched iTunesU videos to another folder. There are two questions:

  1. How to find these videos? Automator is able to filter tracks based on play count, but apparently the tracks do not include iTunesU video
  2. How to prevent iTunes from re-downloading these videos again?
share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can't easily do it with Automator's actions directly, but you can with AppleScript (which you can wrap in an Automator action if you need).

This AppleScript will get all the iTunes U items that have been watched at least once and move them to a folder you specify.

  • Note that this does not remove them from iTunes, and you can still play them from iTunes (this is because of how OS X apps track files - in most apps you can move a file you have open and the app can still access it as if nothing has happened).
  • If you want to remove the item from iTunes altogether, you can add delete theItem on a new line after set the end of theList to the location of theItem.
    • If you want to avoid redownloading, you'll have to manually change the iTunes U download settings (although I'm not sure if iTunes will actually redownload an item that has been deleted - typically it only downloads new items).
  • Be sure to change the path to the destination folder to your desired destination, on the set theDestination … line. It must be a folder that exists already.

Script

tell application "iTunes"
    set theList to {}
    set iTunesU to tracks of playlist "iTunes U"
    repeat with theItem in iTunesU
        try
            if played count of theItem > 0 then
                set the end of theList to the location of theItem
            end if
        end try
    end repeat
end tell

tell application "Finder"
    set theDestination to POSIX file "/Users/rob/Desktop/test/"
    repeat with theFile in theList
        move theFile to theDestination
    end repeat
end tell
share|improve this answer
    
thank you very much! is there a specific reason to save the locations first, and move the files in separate loop? –  zeliboba Dec 2 '12 at 21:58
    
I separated them like that because the move action needs to be done by Finder, and I felt it was more readable this way. But you could certainly condense it by doing a direct tell to the Finder within the first loop, and do away with the list altogether. But it's really just a question of style, both will have the same outcome. –  robmathers Dec 2 '12 at 22:05
    
I just made a gist out of the more concise version of this code, which you can find here. –  robmathers Dec 2 '12 at 22:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.