Chaning one script line of many files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am working on an important project involving hundreds of html files, having
exactily the same data except for one part of one line. This is a tow-digit
number on the line for the name of an image. I was wonderinig if it is
possible to simultaneously change this data in all the files ascending or
decending so the task isn't so tedious editing each one individually.
Any and all help is desired.
Thanks, Arthur
 
smartA said:
I am working on an important project involving hundreds of html files, having
exactily the same data except for one part of one line. This is a tow-digit
number on the line for the name of an image. I was wonderinig if it is
possible to simultaneously change this data in all the files ascending or
decending so the task isn't so tedious editing each one individually.
Any and all help is desired.
Thanks, Arthur

Your best bet is a "Search and Replace" command line tool. I typed
this into the Google search field and got thousands of links:

"Search and Replace" "command line" free
 
The programs I saw only changed the data to the same thing. However, I am
only interested in a program that can replace a piece of data in many files
with an increased number for each subsequent file - each one goes up one
number as it proccesses the files, if they are all the same.
Thanks
Arthur
 
Let's have an actual example, please!


smartA said:
The programs I saw only changed the data to the same thing. However, I am
only interested in a program that can replace a piece of data in many files
with an increased number for each subsequent file - each one goes up one
number as it proccesses the files, if they are all the same.
Thanks
Arthur
 
For example:
the line in the first html file is:
<img src="../../DiskOne/IM_A0001.JPG"></a>
the second file:
<img src="../../DiskOne/IM_A0002.JPG"></a>
the third:
<img src="../../DiskOne/IM_A0003.JPG"></a>
and so on...
 
You would have to use a combination of batch
commands and "search and replace". Assuming
that bkreplacem.exe (as suggested by Dog) is
your search and replace tool, you could do this:

@echo off
cd /d "c:\Documents and Settings\My Pics"
set counter=0
for %%a in (*.jpg) do call :Sub %%a
goto :eof

:Sub
set /a counter=%counter% + 1
bkreplacem "%1" ... ... ...

What parameters you exactly place into the search and
replace command I do not know, because your example
is insufficiently detailed: It does not tell us what string
you're looking for, and it does not tell us what you want
to replace it with. It simply mentions an incrementing
counter, and this is exactly what the above batch file
gives you.
 
Back
Top