Files
CSVFileSync/csv_file_sync.py
T
2025-09-20 00:07:40 +02:00

22 lines
563 B
Python

import os
import csv
download_folder = "YOUR_FILE_DIRECTORY_PATH"
csv_file = "YOUR_CSV_FILE_PATH"
playlist_tracks = set()
with open(csv_file, newline='', encoding='utf-8') as f:
reader = csv.reader(f)
for row in reader:
row = row[:-1]
filename = f"{row[1]} - {row[0]}.mp3"
playlist_tracks.add(filename)
# Scan download folder
for file in os.listdir(download_folder):
if file not in playlist_tracks:
file_path = os.path.join(download_folder, file)
os.remove(file_path)
print(f"Deleted File: {file}")