Reputation: 5
i'm trying to use a batch file to read through all the elements of my .xml file to retrieve the file path and execute them in order like a playlist. heres an example of my .xml file:
<Sunday>
<id>1</id>
<filePath>\\MOVIESERVER\movie1.mkv</filePath>
</Sunday>
<Sunday>
<id>2</id>
<filePath>\\MOVIESERVER\movie2.avi</filePath>
</Sunday>
<Sunday>
<id>3</id>
<filePath>\\MOVIESERVER\movie3.avi</filePath>
</Sunday>
<Sunday>
<id>4</id>
<filePath>\\MOVIESERVER\Movie4.avi</filePath>
</Sunday>
</dataroot>
right now i'm using this batch file but it only reads the first element "\MOVIESERVER\movie1.mkv" how do i get it to either loop through or line by line pull out the filepaths in order?
@echo off
for /f "tokens=2 delims=<>" %%a in ('type "C:\VlcTV\VLCPlaylists\Programs\Version_3.0\00-Sun.xml" ^|find /i "<filepath>" ') do set "var=%%a"
any suggestions will be greatly appreciated :)
Upvotes: 0
Views: 68
Reputation: 9545
You have to activate the delayed expansion :
@echo off
setlocal enabledelayedexpansion
for /f "tokens=2 delims=<>" %%a in ('type "C:\VlcTV\VLCPlaylists\Programs\Version_3.0\00-Sun.xml" ^|find /i "<filepath>" ') do (
set var="%%a"
echo !var!)
Upvotes: 1