Solved Extracting newest XML files with .bat

April 4, 2017 at 20:08:19
Specs: Windows 7
Hey all,

I had to remove my last post since it wasn't describing clearly my problem.

I have a batch script which should normally work. It should extract certain values I need from XML files as well as extracting only the newest XML files ( for example today. 05.04.17 ).

Anyway, somehow it doesn't work. It shows me always: The system cannot find file specified.

My old batch script which doesnt include the newest date extract works fine:

@echo off&setlocal EnableDelayedExpansion&set n=0&set m=0&set f=0&c=0&set d=0
cls&echo Enter the amount of variables you want to save the value of(1-9):
choice /c 123456789 /n>nul
set vars=%errorlevel%
:loop
if %n% equ %vars% for /f %%A in ('dir /b ^| find ".xml"') do set "file=%%A"&goto folderloop
set /a n+=1
cls&echo Enter the name of variable %n%(CAPS sensitive) ^& hit enter:
set /p "var%n%="
goto loop
:folderloop
for /f %%A in ('dir /b ^| find ".xml"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f %%A in ('dir /b ^| find ".xml"') do set "file!c!=%%A"&goto indexing
for /f "skip=%d%" %%A in ('dir /b ^| find ".xml"') do set "file!c!=%%A"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type %file% ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not %vars% equ %m% goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type %file% ^| find "%tmp%"') do set val%var%=%%1
if not !var! equ %vars% goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%>>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
start notepad outputfile.txt
exit /b

------------------------------------------------------
My batch script with date extract doesnt work somehow. I tried to fix it myself and compared it with "beyond compare" but I still have no solution for it:
-------------------------------------------------------

test.bat
-------------------------------
@echo off&setlocal EnableDelayedExpansion&set n=0&set m=0&set f=0&c=0&set d=0
cls&echo Enter the amount of variables you want to save the value of(1-9):
choice /c 123456789 /n>nul
set vars=%errorlevel%
:loop
if %n% equ %vars% for /f "tokens=4" %%A in ('dir /4 ^| find "%date:~-10%" ^| find ".xml"') do set "file=%%A"&goto folderloop
set /a n+=1
cls&echo Enter the name of variable %n%(CAPS sensitive) ^& hit enter:
set /p "var%n%="
goto loop
:folderloop
for /f "tokens=4" %%A in ('dir /4 ^| find "%date:~-10%" ^| find ".xml"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f "tokens=4" %%A in ('dir /4 ^| find "%date:~-10%" ^| find ".xml"') do set "file!c!=%%A"&goto indexing
for /f "skip=%d% tokens=4" %%A in ('dir /4 ^| find "%date:~-10%" ^| find ".xml"') do set "file!c!=%%A"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type %file% ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not %vars% equ %m% goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type %file% ^| find "%tmp%"') do set val%var%=%%1
if not !var! equ %vars% goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%>>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
start notepad outputfile.txt
exit /b


Maybe someone can help me out here. Trying to solve it :(. Sorry for the long post ! Thanks for the help in advance


See More: Extracting newest XML files with .bat

Report •

✔ Best Answer
April 6, 2017 at 02:52:20
this is one of my older versions which should still work

I'm gonna go get lunch btw, tty in a bit

@echo off&setlocal EnableDelayedExpansion&set n=0&set m=0&set f=0&set c=0&set d=0
set vars=3
set var1=testTime
set var2=testDuration
set var3=shortNUM
for /f %%A in ('dir /b ^| find ".xml"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f %%A in ('dir /b ^| find ".xml"') do set "file!c!=%%A"&goto indexing
for /f "skip=%d%" %%A in ('dir /b ^| find ".xml"') do set "file!c!=%%A"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type "%file%" ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not %vars% equ %m% goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type "%file%" ^| find "%tmp%"') do set val%var%=%%1
if not !var! equ %vars% goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%^ >>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
exit /b

Simple solutions are often the best

message edited by hidde663



#1
April 5, 2017 at 01:51:28
huehue, let me try again :)

i changed my cmdprompt to english this time

can you run these command for me from cmd.exe?:

pushd "THE LOCATION OF YOUR XML FOLDER"

echo %date:~-10%

for /f "tokens=4" %a in ('dir /4 ^| find "%date:~-10%" ^| find ".xml"') do echo %a

---------------

and could you tell me what systemlanguage you are using?
Simple solutions are often the best

message edited by hidde663


Report •

#2
April 5, 2017 at 02:17:22
@echo off&setlocal EnableDelayedExpansion&set n=0&set m=0&set f=0&c=0&set d=0
cls&echo Enter the amount of variables you want to save the value of(1-9):
choice /c 123456789 /n>nul
set vars=%errorlevel%
:loop
if !n! equ !vars! for /f "tokens=3,*" %%A in ('dir /4 ^| find ".xml" ^| find "%date:~-10%"') do set "file=%%B"&goto folderloop
set /a n+=1
cls&echo Enter the name of variable !n!(CAPS sensitive) ^& hit enter:
set /p "var!n!="
goto loop
:folderloop
for /f "tokens=3,*" %%A in ('dir /4 ^| find ".xml" ^| find "%date:~-10%"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f "tokens=3,*" %%A in ('dir /4 ^| find ".xml" ^| find "%date:~-10%"') do set "file!c!=%%B"&goto indexing
for /f "skip=%d% tokens=3,*" %%A in ('dir /4 ^| find ".xml" ^| find "%date:~-10%"') do set "file!c!=%%B"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type %file% ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not !vars! equ !m! goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type %file% ^| find "%tmp%"') do set "val%var%=%%1"
if not !var! equ !vars! goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%^ >>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
start notepad outputfile.txt
exit /b

message edited by hidde663


Report •

#3
April 5, 2017 at 02:39:07
Hey Hidde 663.

I'm sort of sorry to bother you with this again ! I ran these commands and it says: 04/05/2017

for: for /f "tokens=4" %a in ('dir /4 ^| find "%date:~-10%" ^| find ".xml"') do echo %a
-->it doesnt respond.

Using windows 7

Along the way: Is there a simple script which runs through hundred of xml files and extracts only these 3(exact) values and put them into a txt ouputfile?

shortNUM, testTime and testDura ?

XML files all look alike :

....
<Info typeKey="000202" shortNUM="0S52042"/>

<testInfo physicalname="DATADATATATA" testTime="2017-04" testDura="0" >
...
<etc etc>

If I could use a simple script it will fix the original problem :)


Report •

Related Solutions

#4
April 5, 2017 at 02:43:11
your date is:04/05/2017
mine date it:05/04/2017

so it was a language problem after all :D

made a fix for it in post #2

Simple solutions are often the best


Report •

#5
April 5, 2017 at 02:53:53
oh haha , my bad !

An error still occurs. I think because all XML files are additonally added with their exact time,e.g: 04/05/2017 7:44 AM , 04/05/2017 1:21 PM , etc etc.

But as I mentioned above. A simple script which ins running trough all files and extracts those 3 values mentioned above will fix that problem. I'd need a script like that anyway :(

message edited by meiyoulimao


Report •

#6
April 5, 2017 at 03:10:43
That shouldn't be a problem, attempted another fix for #2

( I really dislike that there are different ouput -formats/-languages in cmd/batch...
will be switching to powershell soon :O )

Simple solutions are often the best


Report •

#7
April 5, 2017 at 03:16:53
That would be so awesome ! I'am highly thankful for all your help!

Yeah, it is annoying somehow :( , before that fix it said
Error: no files found with date : 04/05/2017

After your fix it says:
Error: no files found with date: 05/04/2017

>.<

still think its a probem with time, since every XML data is generated automatically with its date + time added

message edited by meiyoulimao


Report •

#8
April 5, 2017 at 03:18:59
one more time sorry, was still editing the post :D

will be getting lunch btw, tty in a bit

Simple solutions are often the best

message edited by hidde663


Report •

#9
April 5, 2017 at 03:24:15
haha sorry !

Mhm the error with the date won't appear but now we have that problem again that I can type in as many values as I want ( loop) ,e.g:

Enter the name of variabel...

The loop won"t close even tho i check only for 2 values or so!

Alright have a good one :) checking on you later :)

message edited by meiyoulimao


Report •

#10
April 5, 2017 at 03:29:14
could you run 1 more command for me from cmd.exe?:

pushd "THE LOCATION OF YOUR XML FOLDER"

dir /4

------------------

remove anything you dont want me to see :)

Simple solutions are often the best


Report •

#11
April 5, 2017 at 03:41:24
Directory of C:\Users\Desktop\Tracking

04\03\2017 01:06 < DIR> .

04\03\2017 01:06 < DIR> . .

04\03\2017 10:30 < DIR> 20AM

04\03\2017 10:30 < DIR> 20PM

04\03\2017 01:06 2.199 apdm.bat

etc etc which is irrelevant I guess :o

Need to go out for a while, checking on you later ! Would be so happy if you would have a script also for these 3 values. Already feel sorry for asking so much... Later :)

message edited by meiyoulimao


Report •

#12
April 5, 2017 at 04:06:36
wow i used the wrong slash... / instead of \ changed #2 once more

and don't worry about asking, I kinda like scripting& fixing buggs

Simple solutions are often the best

message edited by hidde663


Report •

#13
April 5, 2017 at 07:45:07
Yet another attempt (works for me again), also escapes ">" chars now

check #2

Simple solutions are often the best


Report •

#14
April 5, 2017 at 19:11:35
Sorry for not replying earlier. Had to work on other stuff :(

mhm no Data error this time but still endless loop. Can we try a simple script with those three values as mentioned in #3 ? It would do the job hehe :)


Report •

#15
April 6, 2017 at 01:44:47
Here is a workaround:

if it doesnt work, we may have to drop the whole date thingy

test.bat
-------------------------------
@echo off&setlocal EnableDelayedExpansion&set n=0&set m=0&set f=0&set c=0&set d=0
cls&echo Enter the date thats in the title of the files you are looking for ^& hit enter:
set /p date1=
cls&echo Enter the amount of variables you want to save the value of(1-9):
choice /c 123456789 /n>nul
set vars=%errorlevel%
:loop
if !n! equ !vars! goto folderloop
set /a n+=1
cls&echo Enter the name of variable !n!(CAPS sensitive) ^& hit enter:
set /p "var!n!="
goto loop
:folderloop
for /f "tokens=4" %%A in ('dir /4 ^| find ".xml" ^| find "%date1%"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f "tokens=3,*" %%A in ('dir /4 ^| find ".xml" ^| find "%date1%"') do set "file!c!=%%B"&goto indexing
for /f "skip=%d% tokens=3,*" %%A in ('dir /4 ^| find ".xml" ^| find "%date1%"') do set "file!c!=%%B"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type "%file%" ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not !vars! equ !m! goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type "%file%" ^| find "%tmp%"') do set "val%var%=%%1"
if not !var! equ !vars! goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%^ >>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
start notepad outputfile.txt
exit /b
------------------------------

Simple solutions are often the best

message edited by hidde663


Report •

#16
April 6, 2017 at 02:15:47
RE #4 (does not check date no more in this one nor does it ask for variable confirmation)

@echo off&setlocal EnableDelayedExpansion&pushd "%~dp0"&set n=0&set m=0&set f=0&set c=0&set d=0
set vars=3
set var1=testTime
set var2=testDuration
set var3=shortNUM
for /f "tokens=4" %%A in ('dir /4 ^| find ".xml"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f "tokens=3,*" %%A in ('dir /4 ^| find ".xml"') do set "file!c!=%%B"&goto indexing
for /f "skip=%d% tokens=3,*" %%A in ('dir /4 ^| find ".xml"') do set "file!c!=%%B"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type "%file%" ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not !vars! equ !m! goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type "%file%" ^| find "%tmp%"') do set "val%var%=%%1"
if not !var! equ !vars! goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%^ >>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
start notepad outputfile.txt
exit /b

Simple solutions are often the best

message edited by hidde663


Report •

#17
April 6, 2017 at 02:18:04
I'd say drop the whole date thing:

It gave me the error:( not because of the date I think)
token=3,* was unexpected at this time.
the syntax of the command is incorrect.

Furthermore. If it would look automatically for those 3 values without typing them in every time would be better. A simple script which looks through those XML files would be doing the job just fine :)

@#16 Why does it still say: the system cannot find the file specified? :O

message edited by meiyoulimao


Report •

#18
April 6, 2017 at 02:25:19
post #16 is what you asked in #17 :D

Simple solutions are often the best


Report •

#19
April 6, 2017 at 02:26:36
Why does it still say: the system cannot find the file specified? :O @post#16

message edited by meiyoulimao


Report •

#20
April 6, 2017 at 02:30:07
I'm starting to run out of ideas, refresh the page, and try #16 1 last time

Simple solutions are often the best


Report •

#21
April 6, 2017 at 02:33:13
Still the same :(

i dont't get it. The old script #1 works fine and finds the files etc. #16 doesn't :(

message edited by meiyoulimao


Report •

#22
April 6, 2017 at 02:52:20
✔ Best Answer
this is one of my older versions which should still work

I'm gonna go get lunch btw, tty in a bit

@echo off&setlocal EnableDelayedExpansion&set n=0&set m=0&set f=0&set c=0&set d=0
set vars=3
set var1=testTime
set var2=testDuration
set var3=shortNUM
for /f %%A in ('dir /b ^| find ".xml"') do set /a f+=1
:skip1
set /a c+=1
set /a d=!c!-1
if !d! equ 0 for /f %%A in ('dir /b ^| find ".xml"') do set "file!c!=%%A"&goto indexing
for /f "skip=%d%" %%A in ('dir /b ^| find ".xml"') do set "file!c!=%%A"&goto indexing
:indexing
set file=!file%c%!
set /a m+=1
set temp=!var%m%!
for /f "tokens=1-26 delims== """ %%a in ('type "%file%" ^| find "%temp%"') do (
if '%%a'=='%temp%' set val!m!=1
if '%%b'=='%temp%' set val!m!=2
if '%%c'=='%temp%' set val!m!=3
if '%%d'=='%temp%' set val!m!=4
if '%%e'=='%temp%' set val!m!=5
if '%%f'=='%temp%' set val!m!=6
if '%%g'=='%temp%' set val!m!=7
if '%%h'=='%temp%' set val!m!=8
if '%%i'=='%temp%' set val!m!=9
if '%%j'=='%temp%' set val!m!=10
if '%%k'=='%temp%' set val!m!=11
if '%%l'=='%temp%' set val!m!=12
if '%%m'=='%temp%' set val!m!=13
if '%%n'=='%temp%' set val!m!=14
if '%%o'=='%temp%' set val!m!=15
if '%%p'=='%temp%' set val!m!=16
if '%%q'=='%temp%' set val!m!=17
if '%%r'=='%temp%' set val!m!=18
if '%%s'=='%temp%' set val!m!=19
if '%%t'=='%temp%' set val!m!=20
if '%%u'=='%temp%' set val!m!=21
if '%%v'=='%temp%' set val!m!=22
if '%%w'=='%temp%' set val!m!=23
if '%%x'=='%temp%' set val!m!=24
if '%%y'=='%temp%' set val!m!=25
if '%%z'=='%temp%' set val!m!=26
)
if not %vars% equ %m% goto indexing
set var=0
:confirmvar
set /a var+=1
set tmp=!var%var%!
set /a value1=!val%var%!+1
for /f "tokens=%value1% delims== """ %%1 in ('type "%file%" ^| find "%tmp%"') do set val%var%=%%1
if not !var! equ %vars% goto confirmvar
:output
echo %val1% %val2% %val3% %val4% %val5% %val6% %val7% %val8% %val9%^ >>outputfile.txt
if not !c! equ !f! set m=0&goto skip1
exit /b

Simple solutions are often the best

message edited by hidde663


Report •

#23
April 6, 2017 at 03:31:20
Awesome ! #22 works just fine ! Thanks for all the effort. Really !

Report •

#24
April 6, 2017 at 04:00:25
np, im still a bit dissapointed tho, since it didnt work on your system while its fine on mine :/

anyways, have a good one :D

Simple solutions are often the best


Report •

#25
April 6, 2017 at 19:11:15
You really helped me out so much ! Thank you many times :)

Report •

Ask Question