Hi
Please I need your help with this script.
I have an logfile.xml and I need to picks the file names of the path but not duplicate and writes them into a bat file, like copy %windiw&\system32\<filename> %1%
Output example for my .bat file should look like
copy %windiw&\system32\ dbghelp.dll %1%
copy %windiw&\system32\ Riched32.dll %1%
copy %windiw&\system32\ imm32.dll %1%
This is my Logfile.xml
<?xml version="1.0" encoding="UTF-8"?>
<Company>Sysinternals - www.sysinternals.com</Company>
<module>
<Timestamp>130412795960224800</Timestamp>
<BaseAddress>0x6de80000</BaseAddress>
<Size>24576</Size>
<Path>C:\Windows\system32\Riched32.dll</Path>
<Version>6.1.7600.16385 (win7_rtm.090713-1255)</Version>
<Company>Microsoft Corporation</Company>
<Description>Wrapper Dll for Richedit 1.0</Description>
</module>
<module>
<Timestamp>130412795960224800</Timestamp>
<BaseAddress>0x6f3b0000</BaseAddress>
<Size>65536</Size>
<Path>C:\Windows\system32\napinsp.dll</Path>
<Version>6.1.7600.16385 (win7_rtm.090713-1255)</Version>
<Company>Microsoft Corporation</Company>
<Description>E-mail Naming Shim Provider</Description>
</module>
The snippsat code
import os
import xml.etree.ElementTree as ET
tree = ET.parse("Logfile.xml")
root = tree.getroot()
for element in root.iter('Path'):
file_name = os.path.basename(element.text)
#.exe just an example that you can have more values
if not file_name.endswith(('.exe', '.fmt', 'sys', 'tmp')):
print element.text
#print os.path.basename(element.text)