The unwanted playlists when I choose to "Add to LIbrary" all my thousands of MP3 files are a nuisance. What's much more important is the disc space consumed by making one extra copy for each MP3 when it appears in a playlist on an external drive.
If "myfile.mp3" is added, and isn't referred to in any playlist a single copy of it is made on my iMac. If it appears in one playlist, an additional file ("myfile 1.mp3") is created, with "myfile 2.mp3" for a second playlist and so on, and these additional files appear in the list of songs in iTunes.
Sorry, I didn't tell the whole story!
I have some 20,000 songs which I have accumulated over years on my Windows PC, and transferred over to Ubuntu as Windows became too slow to tolerate on the elderly hardware.
I've just bought a new iMac, and am in the process of transferring everything across from the old PC.
As part of this, I opened iTunes, and chose "Add to Library", giving as the source a shared /Music folder on the old system - this contains subfolders for artist for album and for track, so you would have:
/Music/B.B. King/Deuces Wild/01 - B.B. King - If You Love Me.m4a
There was no apparent option to include or ignore any particular filetype, so I left it running overnight, and came back to find all the duplicates in iTunes, a host of playlists I didn't want, and duplication of the files on my iMac.
Here's a directory listing produced using "ls -Rai" in Terminal of the files imported to my iMac:
./B.B. King/Deuces Wild:
1061304 01 - B.B. King - If You Love Me 1.m4a
1061302 01 - B.B. King - If You Love Me.m4a
1061305 02 - B.B. King - The Thrill Is Gone 1.m4a
1061292 02 - B.B. King - The Thrill Is Gone.m4a
1061306 03 - B.B. King - Rock Me Baby 1.m4a
1061287 03 - B.B. King - Rock Me Baby.m4a
1061307 04 - B.B. King - Please Send Me Someone To Love 1.m4a
1061294 04 - B.B. King - Please Send Me Someone To Love.m4a
1061308 05 - B.B. King - Baby I Love You 1.m4a
1061301 05 - B.B. King - Baby I Love You.m4a
1061309 06 - B.B. King - Ain't Nobody Home 1.m4a
1061293 06 - B.B. King - Ain't Nobody Home.m4a
1061310 07 - B.B. King - Pauly's Birthday Boogie 1.m4a
1061296 07 - B.B. King - Pauly's Birthday Boogie.m4a
1061311 08 - B.B. King - There Must Be A Better World Somewhere 1.m4a
1061299 08 - B.B. King - There Must Be A Better World Somewhere.m4a
1061321 09 - B.B. King - Confessin' The Blues 1.m4a
1061312 09 - B.B. King - Confessin' The Blues.m4a
1061313 10 - B.B. King - Dangerous Mood 1.m4a
1061298 10 - B.B. King - Dangerous Mood.m4a
1061314 11 - B.B. King - Bring It Home To Me 1.m4a
1061288 11 - B.B. King - Bring It Home To Me.m4a
1061315 12 - B.B. King - Paying The Cost To Be The Boss 1.m4a
1061303 12 - B.B. King - Paying The Cost To Be The Boss.m4a
1061316 13 - B.B. King - Let The Good Times Roll 1.m4a
1061300 13 - B.B. King - Let The Good Times Roll.m4a
1061317 14 - B.B. King - Dangerous Mood 1.m4a
1061291 14 - B.B. King - Dangerous Mood.m4a
1061323 15 - B.B. King - Keep It Coming 1.m4a
1061318 15 - B.B. King - Keep It Coming.m4a
1061322 16 - B.B. King - Cryin' Won't Help You Babe 1.m4a
1061319 16 - B.B. King - Cryin' Won't Help You Babe.m4a
1061320 17 - B.B. King - Night Life 1.m4a
1061295 17 - B.B. King - Night Life.m4a
You'll see that each of the tracks is duplicated, the first copy having the track name, and the duplicate having " 1" inserted at the end of the track name and before ".m4a".
I used the "i" option in the ls command to list the inode numbers, to confirm that it's not just a matter of two filenames pointing to the same physical area on the disc, so the disc space consumed by this is significant, particularly when some of the files have three copies.
I'm sure an experienced bash script writer could write a script to remove all these duplicates, but if I could stop them happening as I hit "Add to LIbrary" I could delete everything from iTunes and start again.
(I realise that deleting the duplicate files with a script wouldn't remove the duplicate entries in iTunes - these would come up with a "!", and I would need to find some non-manual way of managing these too).
In case anyone is faced with the same problem, here's how I resolved it.
First, I had to delete everything in my iTunes library, along with the imported files in iTunes Media, and start the import process again.
Before that, I had to remove all the M3U files in the Music folder on the network drive I was using to transfer the music from.
There were too many folders with M3U files in them to do this "by hand", so I had to use terminal commands to achieve this.
I changed the current working directory to the main music folder, then used...
find . -type f | sed "s#^.#$(pwd)#" | grep m3u > rmfiles
... to create a file with full paths to all the M3U files in it ("rmfiles").
I thought I would be able to use this as standard input to the rm command, but ended up using my editor to enclose each file in quotation marks (many of them had spaces in the filenames), and prefix each line with "rm " (without the quotes).
Each line read something like:
rm "home/michael/path/to/music/Artiste/Album Name.m3u"
This file could then be run as a shell script, and worked a treat!