Re: replacing text on multiple text files

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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


.



Relevant Pages

  • Re: ActiveX Task - Status = Failure or Success
    ... you must prevent the failure in the first place. ... > then on completion runs a second ActiveX Script to set the first Script ... > but then finds it on the second loop (i.e. reports success), ...
    (microsoft.public.sqlserver.dts)
  • Re: Jumping in at the deep end - and drowning I suspect.
    ... The first script I wrote was about a 419 fraud set in America ... The story revolves around the brother convincing authorities that what ...
    (rec.arts.sf.composition)
  • Re: passing data
    ... >>> So my first script is the data engine, I need to pass various commands to ... >>> using another script. ... > I never said I would use a socket solution, ...
    (comp.lang.perl.misc)
  • Re: Two-way relationship with multiple records - FM6
    ... you can create a portal to visualise the related data. ... You would have to script that through two ... one in each table or that the first script triggers the ... The fired script goes to the related record. ...
    (comp.databases.filemaker)
  • Re: [Powershell] How can I split a string into "words"
    ... arguments to that command from each line in a file. ... this returns empty arguments if multiple spaces separate the words ... ... the arguments to run the first script. ...
    (microsoft.public.windows.server.scripting)