Solved Batch assistance please, trying to put it all together

September 15, 2012 at 10:42:52
Specs: Windows 7
good day all, well im trying to figure out that proper batch command that can add a string or character to the end and beginning of each line in a txt doc
ed: String1 originaltext String2

I have been able to do this for the beginning of each line
[code(for /f "delims=" %L in (oldfile.txt) do @echo predefined text %L)> newfile.txt[/code]

but im not sure about the end of each line? Also is it possible once the desired text is added to the lines to join the text from lets say links.txt and titles.txt to make for example a desired code

<li class="pureCssMenui"><a class="pureCssMenui" href="https://docs.google.com/open?id=0B_KBy1Yc657LOWNGZkRwd3BSUGM" target="_blank">Applescript in a nutshell.chm</li>

I have 2 txt docs, one with titles of documents and the other with links to the document, im trying to find a way to make it go alot faster than going 1 by one, Thank you in advance


See More: Batch assistance please, trying to put it all together

Report •

#1
September 15, 2012 at 18:26:33
✔ Best Answer
part one, maybe:
(for /f "delims=" %L in (oldfile.txt) do @echo string1 %L string2)> newfile.txt

part two, merging links and titles:
:: ===== start script
@echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in (titles) do (
set /a z+=1
set x!z!=%%a
)
set z=0
for /f "tokens=*" %%a in (links) do (
set /a z+=1
call :f

>>newfile.htm echo ^<a href="%%a"^>!f!^</a^>

)
goto :eof
:f
set f=!x%z%!
::==== end

obviously, this is just the "meat". all the preceding and subsequent content are still to be dealt with. I have a sneaking suspicion it could be done more efficiently, but nevertheless...


Report •

#2
September 15, 2012 at 20:26:46
hey ill give that a try and let you know what happens, I really appreciate your help

Report •
Related Solutions


Ask Question