As I see it you have a few possible options…
- See if dougscripts can help http://dougscripts.com/itunes/scripts/ss.php?sp=makeatextlist (there probably are other scripts on there that may help - search for 'export' on the site - some others are mentioned at Parsing iTunes XML).
- Parse the .xml into the fields you desire (probably via a Python script or similar). I suspect there will be something around if you are willing to search & try running them. This should give the best output but may take some work.
- Parse the output of a directory listing (assuming iTunes manages the location of the media), the next commands will create a list based on the folder structure of the iTunes Library - it does not list compilations correctly, you will need to handle them separately. This may not be what you want, especially if you want a subset of the library.
cd ~/Music/iTunes/iTunes\ Music/Music
find . -type d -maxdepth 1 -exec find {} -type d -mindepth 1 \; | sed -e 's|./||' -e 's|/| |'
NOTE: You may need to provide a different path to the music folder, mine has been migrated over many years & may not be the same as yours (drag & drop to get the Terminal to auto fill correcting any spaces in the path).
It outputs like …
A Tribe Called Quest The Anthology
Add N to (X) Add Insult to Injury
Add N to (X) Avant Hard
…
In short it finds folders one level deep, then inside those find the next folder names and parse out the leading './' and convert the next slash to 4 spaces.
You may want to change the spaces to commas so you can import to a spreadsheet, however that will need careful handling when Albums or Artists contain commas.
This next one is cleaner, again run it from inside the music folder
cd ~/Music/iTunes/iTunes\ Music/Music
ls */ | sed -e '/^$/d' -e 's/\(.*[^/\:]\)$/ \1/' -e 's|\/\:||'
It looks more like your original aim
…
Orbital
Blue Album
In Sides
Orbital II
Orchestral Manoeuvres in the Dark
Peel Sessions 1979-1983
Hope that's some food for thought.