Reputation: 661
I need to generate an xml from windows command prompt using the forfiles command.
I'm not so far, but the variable contains quotes and i don't want it ...
Here my current command:
%FF_CMD% /c "cmd /c if @isdir==TRUE echo ^<root^>^<dir^>@fname^</dir^>^</root^>"
the result is:
<root><dir>"DIRNAME"</dir></root>
but i want this:
<root><dir>DIRNAME</dir></root>
any idea ?
thanks in advance
Upvotes: 5
Views: 5666
Reputation: 2950
You can create additional batch file, say "echoxml.bat". This will allow to use ~
notation to strip quotes:
@echo off
echo ^<root^>^<dir^>%~1^</dir^>^</root^>
and then use the batch file in forfiles:
%FF_CMD% /c "cmd /c if @isdir==TRUE echoxml.bat @fname"
EDIT:
Another option would be to change forfiles
to for
, or even for /d
if it is possible (I do not know what arguments you use in %FF_CMD%
):
@echo off
for /d %%A in (*) do echo ^<root^>^<dir^>%%~A^</dir^>^</root^>
Upvotes: 7