This cannot be done through iTunes. It will not work with an iPod touch or an iPhone. It involves a few separate steps:
This is different depending on the version of iTunes, but basically you need to go to Preferences, deselect the synch automatically button, and enable the Enable Disk Use option. The exact wording may be different.
Next, you need to force your Mac to display all hidden files. Open the Terminal application on your Mac and type the following text, pressing the return key after each line:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Connect your iPod to your Mac while holding down the Option and Command keys. This will cause the iPod to connect as a hard disk. If iTunes tries to turn on, make it quit. The iPod will appear on your desktop.
Double click the iPod icon to open it up and look for the iPod_Control folder, open that and you will see a number of sub-folders, including a Music folder. This is the folder where all of your audio and video files reside. (Photos and games are stored elsewhere if you have them.) Simply copy all of the files in the Music folder to a folder you create on your Mac. This folder can be anywhere.
Open iTunes and make sure that Copy files to iTunes Music folder when adding to library option is enabled in your iTunes advanced preferences. Then simply go File > Add to library and import all these files into iTunes on your Mac. Once you have done this you can delete the folder with all the copied files in them if you want to, because they will all now be in iTunes anyway. Or keep it as a backup somewhere.
As a final step it's a good idea to stop your Mac from displaying the hidden files because it will soon become annoying. Go back to Terminal and type the following text, pressing the return key after each line:
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
This is adapted from iLounge.com, where you can find instructions if you are unfortunate enough to use Windows.