I have been tasked with this at work and have had a crash course in batch scripting over the 2 days, I am not a developer or scripter but am keen to learn so please bare with me. I am almost complete in achieving what I need to do, please kindly help.
Problem
I need to find a string in a line contained in an XML file using inputs from an INI file. When I find that string, I need to find another string in that same line and rename the second string with the name of the first string, then copy that physical file from the first string into a different folder pre-determined by settings in the INI file. Then lastly to rename the second string's file name with that of the first strings filename. Hope that makes sense.
Here is my batch script:
Code: Select all
title [ + MAIN MENU + "x" TO EXIT ]
cls
set /p answer=Press 1 to Begin:
if /i "%answer%"=="1" goto Begin
if /i "%answer%"=="x" goto eof
:: FIRST SECTION
:Begin
Set inifile="settings.ini"
FOR /F "delims== tokens=2* usebackq" %%i in (`type %inifile% ^| find "xmlPath="`) do (set xmlpath=%%i)
echo %xmlpath% > xmlpath.txt
FOR /F "delims== tokens=2* usebackq" %%i in (`type %inifile% ^| find "fileinXml="`) do (set fileinxml=%%i)
echo %fileinxml% > fileinxml.txt
fart.exe %xmlpath% %fileinxml%
:: As above I used a 3rd party app to 1. find the file, 2. find the matching text, just not sure how to find the 2nd string, please see below.
::I AM STUCK HERE, I can find MENU2.JPG but need to grab the data by [b]LocalFilename[/b] which would look like this
:: [quote]<File FileId="117765" FileName="MENU2.jpg" LocalFilename="117765" Hash="968e9cb2b38b2161f350903afe9040b7" Size="96690" Type="application/octet-stream" />[/quote]
:: Then once I am able to grab the data from that 2nd string [i]LocalFilename[/i] then I can copy the MENU2.jpg to the required destination and rename the previous match.
:eof
endlocal
exit
This is my settings.ini file
Code: Select all
xmlPath=C:\campaigns\16914\document.xml
fileinXml=C:\campaigns\16914\MENU2.jpg
destination=C:\campaigns\16922\
Hope this question makes sense and that I have presented enough information. I appreciate any assistance. Thank You.