How to use Applescript to find duplicate files and .mp3 files in my iTunes "Music" folder and subfolders?
Doug's AppleScripts for iTunes have helped me a great deal. Try Dupin for cleaning those duplicate files. There's also a lite version.

You can learn a lot about AppleScript by opening scripts by others in script editor so you understand what's happening. Apple also has a comprehensive guide about the language, if you want to read all about it.