Computing.Net > Forums > Windows XP > Find and Replace string with filename

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Find and Replace string with filename

Reply to Message Icon

Name: josh10
Date: November 6, 2009 at 10:21:16 Pacific
OS: Windows XP
Subcategory: Software Problems
Tags: DOS, Batch file, Windows
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: ace_omega
Date: November 6, 2009 at 13:28:56 Pacific
Reply:

"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?


0

Response Number 2
Name: josh10
Date: November 6, 2009 at 13:48:28 Pacific
Reply:

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%"/>


0

Response Number 3
Name: Ewen
Date: November 6, 2009 at 17:05:02 Pacific
Reply:

You should post this in the Programming Forum for more help!

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


-1

Response Number 4
Name: josh10
Date: November 6, 2009 at 18:01:42 Pacific
Reply:

This is someones personal webpage, I'm not sure why it is linked
as a solution.


0

Response Number 5
Name: Mechanix2Go
Date: November 6, 2009 at 18:21:55 Pacific
Reply:

@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


0

Related Posts

See More



Response Number 6
Name: josh10
Date: November 6, 2009 at 19:07:31 Pacific
Reply:

AWESOME!!!! That worked like a champ. Thank you very
much!


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Find and Replace string with filename

find and replace text with the command prompt www.computing.net/answers/windows-xp/find-and-replace-text-with-the-command-prompt/176284.html

Find and replace string in a file www.computing.net/answers/windows-xp/find-and-replace-string-in-a-file-/138358.html

multiple find and replace www.computing.net/answers/windows-xp/multiple-find-and-replace/175096.html