Opening files from a file containing file paths as a .csv

Feature requests for VLC.
CaptainCatFlex
New Cone
New Cone
Posts: 8
Joined: 12 Sep 2024 04:29

Opening files from a file containing file paths as a .csv

Postby CaptainCatFlex » 24 Sep 2024 01:39

Hello there,

I wanted to know if it was possible in the current version to open a list of file paths that are stored in a file as a .csv?

As an example, here I have a file named "files.csv" that contains the following:
"
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
"
As a feature, all files would be put in a playlist in this case, since they are music files.

Rémi Denis-Courmont
Developer
Developer
Posts: 15311
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Opening files from a file containing file paths as a .csv

Postby Rémi Denis-Courmont » 24 Sep 2024 13:29

CSV with a single column isn't really CSV.

You can write one URL per line and name it .m3u
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

CaptainCatFlex
New Cone
New Cone
Posts: 8
Joined: 12 Sep 2024 04:29

Re: Opening files from a file containing file paths as a .csv

Postby CaptainCatFlex » 24 Sep 2024 21:46

.m3u, got ya, thank you.

CaptainCatFlex
New Cone
New Cone
Posts: 8
Joined: 12 Sep 2024 04:29

Re: Opening files from a file containing file paths as a .csv

Postby CaptainCatFlex » 15 Oct 2024 00:25

Well here I come again, for a .m3u to be read, it will require
#EXTM3U
#EXTINF: <ID>, ...
<Path>
..
Is there not a way I can just open up a file containing file paths of my musics?

I am reorganizing playlists using my python codes and a plain text file with only filepaths would be enjoyable.

For the moment, my file.m3u will not open in VLC.

CaptainCatFlex
New Cone
New Cone
Posts: 8
Joined: 12 Sep 2024 04:29

Re: Opening files from a file containing file paths as a .csv

Postby CaptainCatFlex » 15 Oct 2024 00:34

Hey there, it seems that for some reason or other, adding the prefix "file:///" to the paths works!
as for example:

"
file:///D:\Misc\Private\Music\Perfect Dark - Institute Menu.mp3
file:///D:\Misc\Private\Music\Perfect Dark Alien Conflict.mp3
file:///D:\Misc\Private\Music\Perfect Dark Deep Sea Nullify Threat.mp3
file:///D:\Misc\Private\Music\Perfect Dark Maian Tears.mp3
file:///D:\Misc\Private\Music\Perfect Dark Soundtrack Skedar Mystery (1080p).mp3
"

will successfully open and read files. The only thing is that it will display the ugly "file:///"+filepath in the displaying playlist file names.

rsd
New Cone
New Cone
Posts: 2
Joined: 29 Jul 2023 00:59

Re: Opening files from a file containing file paths as a .csv

Postby rsd » 07 Dec 2024 22:32

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:

Code: Select all

python convert_csv_to_m3u.py

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)


Return to “VLC media player Feature Requests”

Who is online

Users browsing this forum: No registered users and 11 guests