Sorry to read about this mishap. Hopefully you can get all your music back. However, Sonar did exactly what it was designed to do, in this case. The problem is that it was designed a long time ago.
Before we had per-song folders, Sonar (or Cakewalk Pro Audio as it used to be called) would store all your wave files in one dedicated folder,
entirely separate from your project files. The idea is that every wave file in that folder had been created by Cakewalk at some point, in the course of working on a song. Sometimes you'd record some audio, then delete the take, and Cakewalk wasn't smart enough to know that it could then delete the audio. Sometimes you wouldn't want it to, anyway - perhaps you might have referenced the same piece of audio in 2 different projects, if you had 2 different versions of the same song, for example.
What Clean Audio Folder would do, is go and remove all the audio files from this shared folder that were not currently being used by any Cakewalk project. This meant two things:
- It would have to search every folder of all of your hard drives to find every Cakewalk project, in order to see what audio each one references. This is why it takes so long. It doesn't only search project folders; in fact, it's for the opposite case, where audio is stored completely separate from the project.
- Once it has that list of which audio files your Cakewalk/Sonar projects are using, it can 'safely' delete every wave file that is in the audio folder and which is not on the list, because it assumes every wave file in the folder was made for a Cakewalk/Sonar project at some point. If it's not on the list, it's no longer being used by Sonar, so it's fair game to be deleted.
Your mistake was telling Sonar that your folder entirely dedicated to Sonar project audio was actually your entire D drive. It was intelligent enough to spot that those files were not referenced by your projects, but it's not intelligent enough to realise that many of the files in there were not created by Sonar in the first place.
For backups, I personally use Crashplan, which will automatically save all your data to a remote server. It's not free, but at times like this, it's almost indispensable.