Last active
December 4, 2025 02:36
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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