This repository contains two Python scripts for comparing and managing files in an Apple Music library. You can use these scripts to verify the integrity of backups, ensure correct synchronization, and manage missing files between two specified folders.
The apple_music_library_comparison.py
script performs a one-way comparison from the source folder to the destination folder and generates a log file containing information about missing files in the destination folder.
Before using this script, make sure you have the following:
- Python installed on your system.
- Required Python libraries:
os
,logging
, andhashlib
.
-
Clone this repository or download the script to your local machine.
-
Edit the script to specify the source and destination folder paths you want to compare.
source_folder_path = "/Volumes/2TB/MusicBackup" destination_folder_path = "/Volumes/2TB/Music/Music/"
-
Run the script using Python:
python apple_music_library_comparison.py
The script will compare files in the specified folders, compute their hashes, and generate a log file named comparison_log.txt
. It performs a one-way comparison from the source folder to the destination folder.
The log file will contain information about missing files in the destination folder.
In case of any errors during the comparison process, the script will log the error details.
The log file will contain the following information:
- Source Folder Path
- Destination Folder Path
- Number of Files Checked
- Missing files and their full paths
- The log file will also include the total number of missing files.
An example log output is included 'comparison_log (example).txt'
The apple_music_library_file_management.py
script builds upon the first script by offering additional functionality to manage missing files in an Apple Music library. It identifies missing files and, if their count is below a specified threshold, copies them to a specified folder.
This script has the same prerequisites as the first script:
- Python installed on your system.
- Required Python libraries:
os
,logging
, andhashlib
.
To use the Apple Music Library File Management Script, follow these steps:
-
Clone this repository or download the script to your local machine.
-
Edit the script to specify the following parameters:
source_folder_path = "/Volumes/2TB/MusicBackup/" destination_folder_path = "/Volumes/2TB/Music/Music/" missing_files_path = "/Volumes/2TB/Missing/" max_missing_files_prompt = 100 # Maximum number of missing files before prompting the user
-
Run the script using Python:
python apple_music_library_file_management.py
The script will perform the same one-way comparison as the first script, identifying missing files in the source folder compared to the destination folder.
It will also attempt to copy missing files to the specified folder (missing_files_path
) if the number of missing files is below a certain threshold (max_missing_files_prompt
).
The script logs its actions and errors in the same comparison_log.txt
file used by the first script.
If the number of missing files exceeds the threshold, the script will log a warning and not attempt to copy the files.
Both scripts are provided under the MIT License.