Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi all,
following batch file creates the list of directory stucture on dirlist.txt. I just want to add some text.
Kindly help!
desired output file
-------------------<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="multiple_input3.xsl"?><someURIs>
<file>C:\kix\Enterprise031114\Enterprise\file.xml</file>
<file>C:\kix\Enterprise031114\Enterprise\AFC\file.xml</file>
<file>C:\kix\Enterprise031114\Enterprise\AHAW\file.xml</file>
</someURIs>dirlist.txt
-----------
C:\kix\Enterprise031114\Enterprise
C:\kix\Enterprise031114\Enterprise\AFC
C:\kix\Enterprise031114\Enterprise\AHAWbatch file:
-----------@echo off
set topdir=C:\kix\Enterprise031114\Enterprise
set tempdir=C:\temp
set file2copy=C:\tree.xsl
set look4file=xmlinterlinks.xmlecho %topdir%> "%tempdir%\dirlist.txt"
dir "%topdir%" /s /b /ad >> "%tempdir%\dirlist.xml"for /F "delims=*" %%p IN (%tempdir%\dirlist.txt) do if exist "%%p\%look4file%" copy "%file2copy%" "%%p"

Below you find the script that converts your text list into a html one; use iit in your batch by calling
Call Lst2Xml DirList.txt DirList.htm
or embed directly in your script.
The trick is straightforward: prefix the forbidden character with a ^ (caret) to strip away its special meaning and use it then as an usual alphameric one.
--- Lst2Xml.bat -----
@Echo Off
:: LST2XML.BAT Syntax: Lst2Xml File_In File_Out
Echo ^<?xml version="1.0" encoding="ISO-8859-1"?^>> %~f2
Echo ^<?xml-stylesheet type="text/xsl" href="multiple_input3.xsl"?^>>> %~f2Echo ^<someURIs^>>> %~f2
For /F "tokens=*" %%A in (%~f1) Do Echo ^<file^>%%A\file.xml^</file^>>> %~f2
Echo ^</someURIs^>>> %~f2

Thanks IVO for the response. I added it in my batch file but i get the error message
Error
-----
The file name, directory name, or volume label syntax is incorrectPlease look at the complete file which is as following
@echo off
set topdir=C:\kix\Enterprise0311141\Enterprise
set tempdir=C:\temp
set file2copy=C:\tree.xsl
set look4file=xmlinterlinks.xml
echo %topdir%> "%tempdir%\dirlist.txt"
dir "%topdir%" /s /b /ad >> "%tempdir%\dirlist.txt"for /F "delims=*" %%p IN (%tempdir%\dirlist.txt) do if exist "%%p\%look4file%" "<file>%%p</file>" > "%tempdir%\dirlist1.txt"
call read_text c:\temp\dirlist.txt dirlist.htm
rem read_text is the bat file IVO wrote

Your flaw is
"<file>%%p</file>"
"^<file^>%%p^</file^>"
remember: prefix with ^ (caret) to have the character interpreted as its own and NOT as a special meaning symbol (redirector in that case)

I am looking again at your script more accurately and I confirm the integrity of my batch (I tested it again and it performed fine); the string in your For statement I brought to your attention in my previous post is still marked as bad, but more *the whole statement following the If clause* is questionable (either coded fine) as it seems meaningless: have you forgotten an Echo command?

yes, you are right ... i was making a mistake in writing the path. thanks!
is it possible that it replaces & with & if it finds in path name?

Please, post your question in other words, explain it, as I do not understand...
> is it possible that it replaces & with & if it finds in path name?
What do you mean?

i just wanted to replace the text '&' with '&'
I have found the way in faq # 19
thanks for your help IVO !

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |