Re: replacing text on multiple text files
- From: "Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 14 Aug 2008 14:55:29 -0600
"chufa72" <chufa72@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:179CCD9C-E0EF-467B-8298-46734DC712FA@xxxxxxxxxxxxxxxx
Hello. I am looking for a way to automatically replace text on multiple
text
files. I am writing my first script for work, but I've hit a brick wall.
The
ways I've tried and failed only work on a single text file at a time.
Thanks,
If you have code that works for a single file, all you need to do is to put
that into a loop where you supply a different filename each time. If your
code looks like this:
file2change = "C:\test\file1.txt"
rem - your code to modify the file
change it to this:
for each file2change in
array("C:\test\file1.txt","C:\test\file2.txt","C:\test\file3.txt")
rem - your code to modify the file
next
This still only does one file at a time, as it does not start processing the
second file until the first has been done. But at least it will process
multiple files in one run of the script.
Depending on the particulars of your situation there could be better ways to
organize this, the most obvious being to pass as a parameter to your script
the name of a file that contains a list of files to be processed. Without
knowing precisely the situation or the code you have working, though, it is
hard to be more specific.
/Al
.
- References:
- replacing text on multiple text files
- From: chufa72
- replacing text on multiple text files
- Prev by Date: Re: replacing text on multiple text files
- Next by Date: Re: replacing text on multiple text files
- Previous by thread: Re: replacing text on multiple text files
- Next by thread: Works in XP but not in Vista
- Index(es):
Relevant Pages
|