Support recursive search of MP3 files in subfolders; update input prompt message

This commit is contained in:
Roncero Blanco, Edgar
2025-05-26 13:57:08 +02:00
parent 9000ff1680
commit 52edae428c

View File

@@ -11,8 +11,8 @@ GROUP_SIZE = 5
# Store the current date # Store the current date
run_date = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") run_date = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Ask for source path # Ask for source path, strip quotes if pasted
source_input = input("Enter the full path to your source MP3 folder: ").strip().strip('"') source_input = input("Drag and drop your music folder here, then press Enter: ").strip().strip('"')
source_media_path = Path(source_input) source_media_path = Path(source_input)
if not source_media_path.exists() or not source_media_path.is_dir(): if not source_media_path.exists() or not source_media_path.is_dir():
@@ -35,9 +35,9 @@ def get_bpm(file_path):
print(f"Skipping {file_path.name} (no BPM): {e}") print(f"Skipping {file_path.name} (no BPM): {e}")
return None return None
# Collect all tracks, grouping unknown BPM separately # Collect all tracks recursively, grouping unknown BPM separately
all_tracks = [] all_tracks = []
for file in source_media_path.glob("*.mp3"): for file in source_media_path.rglob("*.mp3"): # <-- recursive glob
bpm = get_bpm(file) bpm = get_bpm(file)
size = file.stat().st_size size = file.stat().st_size
if bpm is None: if bpm is None: