Created
April 21, 2024 01:58
-
-
Save adamz01h/586f27f9d5de9ed99efaad2a4ac8b089 to your computer and use it in GitHub Desktop.
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
| @echo off | |
| setlocal | |
| :: Check if a file path was provided as an argument | |
| if "%~1"=="" ( | |
| echo No WPL file was dragged onto the script. | |
| pause | |
| exit /b | |
| ) | |
| :: Get the full path of the WPL file | |
| set "WPL_FILE=%~f1" | |
| :: Get the filename without extension to use as the default folder name on the desktop | |
| for %%A in ("%WPL_FILE%") do set "PLAYLIST_NAME=%%~nA" | |
| set "DEFAULT_DEST=%USERPROFILE%\Desktop\PlaylistExport\%PLAYLIST_NAME%" | |
| :: Create the destination folder if it does not exist | |
| if not exist "%DEFAULT_DEST%" ( | |
| echo Creating folder: "%DEFAULT_DEST%" | |
| mkdir "%DEFAULT_DEST%" | |
| ) else ( | |
| echo Folder already exists: "%DEFAULT_DEST%" | |
| ) | |
| :: Define VBScript path | |
| set "VBSCRIPT_PATH=%DEFAULT_DEST%\WPLParser.vbs" | |
| echo VBScript will be created at: "%VBSCRIPT_PATH%" | |
| :: Start VBScript creation | |
| echo Set fso = CreateObject^("Scripting.FileSystemObject"^) > "%VBSCRIPT_PATH%" | |
| echo Set xmlDoc = CreateObject^("Microsoft.XMLDOM"^) >> "%VBSCRIPT_PATH%" | |
| echo xmlDoc.Async = "False" >> "%VBSCRIPT_PATH%" | |
| echo xmlDoc.Load^(WScript.Arguments^(0^)^) >> "%VBSCRIPT_PATH%" | |
| echo Set nodeList = xmlDoc.SelectNodes^("/smil/body/seq/media"^) >> "%VBSCRIPT_PATH%" | |
| echo For Each node in nodeList >> "%VBSCRIPT_PATH%" | |
| echo src = node.getAttribute^("src"^) >> "%VBSCRIPT_PATH%" | |
| echo basePath = fso.GetParentFolderName^(WScript.Arguments^(0^)^) >> "%VBSCRIPT_PATH%" | |
| echo resolvedPath = fso.BuildPath^(basePath, src^) >> "%VBSCRIPT_PATH%" | |
| echo absPath = fso.GetAbsolutePathName^(resolvedPath^) >> "%VBSCRIPT_PATH%" | |
| echo WScript.Echo absPath >> "%VBSCRIPT_PATH%" | |
| echo Next >> "%VBSCRIPT_PATH%" | |
| :: Execute the VBScript to get the absolute file paths | |
| for /f "delims=" %%a in ('cscript //nologo "%VBSCRIPT_PATH%" "%WPL_FILE%"') do ( | |
| echo Copying "%%a" to "%DEFAULT_DEST%" | |
| xcopy "%%a" "%DEFAULT_DEST%" /I /Y | |
| ) | |
| :: Clean up the temporary VBScript file | |
| del "%VBSCRIPT_PATH%" | |
| endlocal |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Drag your working windows media playlist file to this bat, and it will copy all media files to a folder on the desktop.