This is a question from Wil Wheaton's google+, but I would like to get an answer too, stackexchange style.
Suppose you have all your music in a folder called /iTunes/Music. When you add files to iTunes, it puts them inside this folder, so it looks like this:
Suppose you recently eliminated about 10GB of music from your iTunes library, but stupidly left those files inside /iTunes/Music. You have the entire thing backed up and pristine on an external drive, so you don't need to keep that music in that folder.
Here's the question: you want to write a script that will compare your iTunes library to the contents of /iTunes/Music, identify files that are in /iTunes/Music but not the iTunes Library file, and move them to a new folder (probably in /tmp) so you can take a look, then delete them.
One possible solution would be to write a script which puts the output of ls (with appropriate flags) into a file, then diff that file with the contents of Library.xml, and move the resulting files into a new directory. Is it possible to do this?
Maybe there is already an Applescript which can be used to achieve this?