This article explains how to transfer your iTunes library to a new computer. Techniques include using a software application to transfer your iPod or iPhone music to a new computer, using an external hard drive, using the iTunes Backup feature, using Migration Assistant, or using Apple iTunes Match. Instructions apply to macOS 10.14 (Mojave) and earlier. Apple discontinued iTunes in macOS 10.15 (Catalina)
The easiest way to transfer an iTunes library is to use software to copy your iPod or iPhone to a new computer. This method only works if your entire library will fit on your device.
The exact procedure varies depending on the software you use, but generally it works like this:
Download and install the backup and transfer software on the new computer.