| import os |
| import shutil |
| import csv |
|
|
| |
| csv_file_path = 'percorsi.csv' |
| main_no_drums_folder = "No-Drums" |
| |
| audio_extensions = ('.wav', '.mp3', '.aif', '.aiff', '.flac') |
| |
| drum_keywords = ['drum', 'kick', 'snare', 'hihat', 'perc', 'clap', 'cymbal'] |
|
|
| def organize_by_pack_root(): |
| if not os.path.exists(csv_file_path): |
| print(f"Errore: Il file {csv_file_path} non è stato trovato.") |
| return |
|
|
| |
| if not os.path.exists(main_no_drums_folder): |
| os.makedirs(main_no_drums_folder) |
| print(f"Creata cartella principale: {main_no_drums_folder}") |
|
|
| with open(csv_file_path, mode='r', encoding='utf-8') as file: |
| reader = csv.DictReader(file) |
| |
| |
| processed_packs = set() |
| |
| for row in reader: |
| specific_folder = row['Percorso Directory'] |
| |
| if not os.path.exists(specific_folder): |
| continue |
| |
| |
| |
| |
| |
| |
| |
| pack_root = os.path.dirname(specific_folder) |
| |
| |
| if pack_root in processed_packs: |
| continue |
| |
| processed_packs.add(pack_root) |
| print(f"\nAnalisi Root Pack: {pack_root}") |
|
|
| |
| for dirpath, dirnames, filenames in os.walk(pack_root): |
| |
| |
| if main_no_drums_folder in dirpath: |
| continue |
|
|
| for filename in filenames: |
| if filename.lower().endswith(audio_extensions): |
| |
| file_path_full = os.path.join(dirpath, filename) |
| |
| |
| |
| if not any(keyword in file_path_full.lower() for keyword in drum_keywords): |
| |
| destination_path = os.path.join(main_no_drums_folder, filename) |
| |
| |
| if os.path.exists(destination_path): |
| base, extension = os.path.splitext(filename) |
| counter = 1 |
| while os.path.exists(os.path.join(main_no_drums_folder, f"{base}_{counter}{extension}")): |
| counter += 1 |
| destination_path = os.path.join(main_no_drums_folder, f"{base}_{counter}{extension}") |
|
|
| print(f" -> Sposto in root/No-Drums: {filename} (da {dirpath})") |
| shutil.move(file_path_full, destination_path) |
|
|
| print("\nOrganizzazione completata.") |
|
|
| if __name__ == "__main__": |
| organize_by_pack_root() |
|
|