If you have a CSV file containing file paths of your music files and want to convert it into a .m3u playlist that VLC can read, follow these steps:
Step 1: Prepare Your CSV File
Ensure your CSV file (files.csv) contains the file paths, one per line. For example:
D:\Misc\Private\Music\Perfect Dark - Institute Menu.mp3
D:\Misc\Private\Music\Perfect Dark Alien Conflict.mp3
D:\Misc\Private\Music\Perfect Dark Deep Sea Nullify Threat.mp3
D:\Misc\Private\Music\Perfect Dark Maian Tears.mp3
D:\Misc\Private\Music\Perfect Dark Soundtrack Skedar Mystery (1080p).mp3
Step 2: Convert CSV to .m3u Format Using Python
Use the following Python script to read the CSV file and convert it into a .m3u file
Code: Select all
import csv
def convert_csv_to_m3u(input_csv, output_m3u):
with open(input_csv, 'r') as csvfile, open(output_m3u, 'w') as m3ufile:
m3ufile.write("#EXTM3U\n")
reader = csv.reader(csvfile)
for row in reader:
filepath = row[0].strip()
if filepath:
m3ufile.write(f"#EXTINF:0,{filepath}\n")
m3ufile.write(f"{filepath}\n")
# Example usage
input_csv = 'files.csv'
output_m3u = 'playlist.m3u'
convert_csv_to_m3u(input_csv, output_m3u)
Step 3: Run the Script
Run the Python script to generate the .m3u file:
looks at other folders
Code: Select all
import os
def gather_files_from_directories(directories):
file_paths = []
for directory in directories:
for root, _, files in os.walk(directory):
for file in files:
file_paths.append(os.path.join(root, file))
return file_paths
def convert_to_m3u(file_paths, output_m3u):
with open(output_m3u, 'w') as m3ufile:
m3ufile.write("#EXTM3U\n")
for filepath in file_paths:
if filepath:
m3ufile.write(f"#EXTINF:0,{filepath}\n")
m3ufile.write(f"{filepath}\n")
# Example usage
directories = [
r'D:\Misc\Private\Music',
r'D:\Another\Directory\With\Music',
# Add more directories as needed
]
output_m3u = 'playlist.m3u'
file_paths = gather_files_from_directories(directories)
convert_to_m3u(file_paths, output_m3u)