Skip to content

Instantly share code, notes, and snippets.

@coppolaemilio
Last active December 4, 2025 02:36
Show Gist options
  • Select an option

  • Save coppolaemilio/13cdff09abb93ee6ed50f8f300c1327b to your computer and use it in GitHub Desktop.

Select an option

Save coppolaemilio/13cdff09abb93ee6ed50f8f300c1327b to your computer and use it in GitHub Desktop.
Copy all files of a VLC .xspf to a folder with the same name. Place the xspf files alongside the script.
# -*- coding: utf-8 -*-
import os
from urllib.parse import unquote
from xml.dom import minidom
import shutil
import sys
# Read all files alongside this script
for FILE in os.listdir('.'):
if '.xspf' in FILE:
DEST_DIR = FILE.replace('.xspf', '')
# Parse xml and get the file list
file_array = []
xmldoc = minidom.parse(FILE)
itemlist = xmldoc.getElementsByTagName('location')
for s in itemlist:
filevalue = s.firstChild.nodeValue
filevalue = filevalue.replace('file:///', '')
filevalue = unquote(filevalue)
file_array.append(filevalue)
# Creating folder
if not os.path.exists(DEST_DIR):
os.makedirs(DEST_DIR)
# Copy files to new folder
for file in file_array:
head, tail = os.path.split(file)
if os.path.isfile(file):
shutil.copy(file, './' + DEST_DIR + '/' + tail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment