Find and Replace string with filename

November 6, 2009 at 10:21:16
Specs: Windows XP
Thanks in advance the posts on here have
been very helpful and I am almost done. I have
a directory of text files that were created from
a template. Each one has a line that says
1111.pdf. I am need to have a batch file that
will take the file name of each text file and
replace the 1111 with the filename of the that
particular text file. Again any help is
appreciated!

See More: Find and Replace string with filename

Report •


#1
November 6, 2009 at 13:28:56
"replace the 1111 with the filename of the that particular text file"

What is the text file? Does it have the file names in it? Give us an example of what is in the txt file?


Report •

#2
November 6, 2009 at 13:48:28
Let's say the file is name joe.txt. I want to replace the 1111
in the joe.txt file with joe. The text file is an html file with
several lines in it. The lines around where I want to replace
are as follows:

<object
id="PDFObj"
data="../pdf/1111.pdf"
type="application/pdf"
width="100%" height="100%"/>


Report •

#3
November 6, 2009 at 17:05:02
You should post this in the Programming Forum for more help!

Home Page http://ewen.uuuq.com/


Report •

Related Solutions

#4
November 6, 2009 at 18:01:42
This is someones personal webpage, I'm not sure why it is linked
as a solution.

Report •

#5
November 6, 2009 at 18:21:55
@echo off & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%f in ('dir/b *.txt') do (
type nul > newfile
for /f "tokens=* delims= " %%a in (%%f) do (
set S=%%a
set S=!S:1111=%%~Nf!
>> newfile echo !S!
)
copy newfile %%f > nul
)
del newfile


=====================================
Helping others achieve escape felicity

M2


Report •

#6
November 6, 2009 at 19:07:31
AWESOME!!!! That worked like a champ. Thank you very
much!

Report •


Ask Question