Before going into the detail of the guide and explaining yourself how to recreate iTunes library, there are some preliminary steps that I highly recommend you take.
First, if you are still able to launch iTunes successfully, I suggest you run the download all the multimedia content you have purchased with your account and make the consolidation of the library: by doing this, you will be sure to enclose in your iTunes library all the contents you have personally added to the program, plus those you have purchased through the iTunes Store, enclosing them all in the same path.
To run the download the media that you purchased with your Apple ID, you open iTunes (or the application Music, if you use macOS 10.15 Catalina or later) and, if necessary, log into the program: to do this, go to the menu Account> Sign in (above) and enter your Apple ID credentials.
Once this is done, choose the type of content to display (eg. Music), using the drop-down menu located at the top left, and go to the menu Account> Purchases (always at the top), to view the list of content purchased on the iTunes Store. Now, to download it to your computer, click on the icon nuvola corresponding to each content.
Once you have downloaded all the items purchased from the iTunes Store, you are ready to run the consolidation of the iTunes library, which consists in storing all the contents in the same path, in order to facilitate their backup and recovery. So go to the menu File> Library> Organize Library iTunes / Music (top), check the box Consolidate files in the window that opens and give OK, to start consolidating the library.
Once this is done, you can create a backup folder with iTunes library, which should be in the path Music on both Windows and macOS.
To know the exact location of the iTunes library (or Music application) on your computer, launch iTunes / Music go to the menu Edit> Preferences (Or iTunes> Preferences o Music> Preferences on macOS), select the tab Advanced in the window that opens and check the path indicated in the box located under the writing ITunes Media folder location.
Once you have identified the iTunes folder, make a backup by copying it, by simple copy-and-paste, to an external hard drive or a fairly large USB stick.
How to create new iTunes library
You are now ready to take action and discover, in practice, how to recreate iTunes library. Depending on what your needs are, you can choose if create a new library and repopulate it with the content of your interest or if import an existing library you backed up.
Either way, the first step you need to take is completely close iTunes (or the Music application, on macOS 10.15 Catalina and later) and restart the software by pressing and holding the key Shift on the keyboard (which would be the one to capitalize only once), which becomes the key alt, if you are using a Mac.
If you did everything right, a window with three buttons should appear: Logout, to leave the iTunes library as it is and close the window; Choose a library, to import an existing library into iTunes and use it as a new program library, or Create library, to create a new empty library and populate it later with your favorite content.
If you previously had problems with iTunes and / or its library, I highly recommend that you choose the option Create library and to start from scratch: in this case, you will be asked to assign a name to the library and choose the folder in which to save it. To confirm everything, click on the button Save.
Now you have a "clean" library to start from, in which to add all the contents of your interest: to do this, just go to the menu File> Add Files to Library (o Add folder to library), at the top, and select the files to import (e.g. backups of songs and other multimedia files that you had previously saved).
If any of the steps are not clear to you, feel free to consult my guide on how to add songs to iTunes: inside you will find all the information you need.
If, on the other hand, you prefer to restore a previously saved library, make sure you have copied the folder iTunes relative to the latter in the path where you want the new iTunes library to be saved (you can also rename the folder if you want), start iTunes / Music holding down the key Shift / alt on the keyboard and click on the button Choose a library present in the window that appears on the screen.
At this point, through the new window that is proposed to you, go to the path of the library to restore, double-click on the file iTunes Library.coml contained in the latter and, within seconds, the game should be done.
iTunes will use the selected library as the new default library: this means that it will automatically import all the contents of the latter and will add to it the new multimedia contents that you insert in the program. It was a lot easier than you thought, wasn't it?
For more information
If, despite my directions, you still haven't managed to recreate your iTunes library or, in any case, you still have doubts about this procedure, visit Apple's official support page on how to backup and restore your iTunes library on the PC.
In the unfortunate event that even this does not help you, you can try to contact Apple directly, putting into practice the instructions I gave you in my tutorial dedicated to the subject. Good luck!How to recreate iTunes library