I have had the same exact problem for weeks now. However, I found that AVG had something to do with it. I uninstalled AVG and installed Avast. Then it only happened once in a while. Then I was messing around and tried to move the XML file to another folder and I couldn't. It was in use even though Itunes was closed. So I looked at running processes and found that Plex was running. I closed it and no more TEMPS!!!
I am 100% sure the issue (initially) has nothing to do with any anti-virus scanner. I am also 100% sure Siddhi67 has located the origin of the issue: the local backup of Time Machine. The reason that I am sure is simple: I have never installed any anti-virus software and I can reproduce (start and stop) the creation of temp-files by turning the local back-up of Time Machine on and of (using Mountain Tweaks btw). It might be that a virus scanner also 'does' something with this local Time Machine back-up setting, but I am sure Time Machine is causing the issue.
So, I've been fiddling around this afternoon and I appear to have fixed the problem - for me at least - not saying that this will work for everyone.
First I quit iTunes.
Then I deleted all the temp files in the iTunes folder.
Then I performed a Time Machine back up.
Next I went to my Music folder and entered Time Machine. I went back to the back up I had just performed, selected the iTunes folder and clicked restore. This took a while because I have a lot of music...!
I opened up iTunes (this also took a while as it had to check the 'new' library) hey presto, everything was working fine, no more temp files were being created and there was no more weird iTunes Music Library.xml file.
If you do want to attempt this, please be very careful. Make sure you are restoring your most recent version - so don't make any changes (adding or editing music) in between the back up and the restore.
Also you will need a lot of hard drive space (depending on the amount of music you have) because, as your hard drive wipes one version of the library with the other, it will technically make room for two libraries.
So, like I said it worked for me! It might not work for you. Please don't blame me if it doesn't! And, like I said, be very careful when you're restoring! And check and double check that your external hard drive/Time Machine is working properly. I don't want to be blamed if someone accidentally wipes their entire music library!
In summary - for me at least - it appeared that this strange .xml file was the cause of the problem. For whatever reason Time Machine wasn't backing this file up so doing a restore from there fixed the problem for me.
Wax Cat...you may have had an old file laying around there. OSX now names that iTunes file iTunes Library.xml. And is definitely needed within iTunes for other programs to access iTunes.
I wanted to post again and say that Siddhi67's solution has worked 100% for me. Anti-virus programs and old files can also mess things up. But it seems that the .tmp files are created because iTunes is not able to update either the iTunes Library.itl or the iTunes Library.xml files (or both). So the temp files are saved and left in the iTunes folder.
Good luck. If anybody else has found a permanent solution (for you) let us know. This has been a real headache for me and I'm thankful for not having my hard drive fill up with these temp files any more!
Hey there, yes I definitely still have the iTunes Library.xml file. The problem was that I had that file as well as the iTunes Music Library.xml file. In my case it definitely appeared that some kind of conflict between these files was causing the problem. Once I got rid of this file by over-writing my iTunes folder I stopped generating temp files...
Everything is working smoothly now, no probs at all.
After many months of problem free. I found a solution that works for me.
1- I deleated all the temp files created by iTunes.
2- I use a option that at first I had very little hope on it.
In iTunes : File / Library / Organize Library
3- In that window I check the box of Reorganized files in the folder ''Music Library''
And I let iTunes do the work.
It's seems too simple but it worked for me.
My understanding of the problem after all the research is that problem can occure when:
1- You have a massive library
2- You've been updating iTunes for a long time. My library was originaly created in 2007. So everytime iTunes was was doing an major update it was updating the library as well. Which maked sense. But when I was looking at my file strcture in the finder it was organized the ''old way''. After a while problem starts to appear just like an old house.
So that fonction was put in place to update this issue.
My advice for those who have a massive ''old'' iTunes.
MAKE SURE YOUR iTUNES IS TIDY!
Keep your iTunes Media folder organized
Copy files to iTunes Media folder when adding to library.
If needed consolidate files if they are not all at the same place.
This is the more simple solution I find.
The other solution which is extream and painful is to restart your library from scratch.
Keep your media some where and delete all your iTunes and restart from scratch a re import all media.
By chance the first solution worked for me.
Niall Mallyon try this if you have not tried it yet and let me know the result.
Please feel free to ask questions.
This is a case close for me after 11 months of pain...
(on a first world problem)
Thanks for the information.
My library is already 'organised' in this way anyway in that I have that option set in the iTunes Advanced preferences.
For completeness however I unticked the option then reticked and let iTunes do its thing even though in reality nothing was actually changed in terms of my library organisation.
Will monitor and report back as necessary. May be some time though as my last 'fix' (restoring the xml from backup) lasted nearly 4 months.
I deleted the tmp files and used terminal command 'rm' and dragged the location of the 'iTunes Music Library.xml' file to delete it.
I have quit and reopened iTunes several times so I am guessing the recreation of the xml file has correct permissions and this terrible waste of hard drive space is finally over!