What's going to be the most painless way to automate the creation of hundreds of symlinks?

My iTunes Movies folder contains each .mp4 film in an individual folder. These folders are named for the movie they contain and most include artwork as well as the movie file in at least one alternate format.

Because of Plex's limitations, my Plex library is a separate folder that contains only the mp4 files of the movies, which are copies of those in my iTunes Library folder. There are 520 mp4s in there right now and this is obviously a huge waste of space.

So, what I wanna do is somehow scan through all the folders in my iTunes Movie Library, select all the .mp4 files and create symlinks to them in a new Plex Movie Library folder. What's going to be the easiest way to do this?

  • Have you tried anything yet, so we can avoid unnecessary answers. – Ruskes Jun 19 '15 at 5:20

Finder doesn't know about symlinks but Terminal does. So

ln -s ~/iTunes/*/Movies/*/*.mp4 /path/to/plex/folder/

should do the trick (paths need to adapted to your local paths).

  • 1
    Actually, it's probably better to make hard links in this case, just so neither program gets cranky. – William T Froggard Jun 19 '15 at 6:31
  • Good point. For hard links, just omit the -s option. – nohillside Jun 19 '15 at 7:26
  • Awesome, thank you! How would I undo the command in the event that the path changes, etc.? – Kerlix Jun 22 '15 at 12:55
  • Just remove the files in /path/to/plex/folder/ again (works both for soft and hard links) – nohillside Jun 22 '15 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .