Replace text in a text file 
Author Message
 Replace text in a text file

I have some code that creates a batch file on the fly. I am having an
issue with how the dir structures are being read. I need to find a way
to search a text file and out quotes arround and dir or file that has
spaces in it. Do anyone have any sample scripts VBScript's that would
allow me to do this?  i.e.

lets pretend that this is the file:
=========begining of file=================
c:\winnt\system32\vbchkw2k.exe c:\DLL Compile Checker
path2
path3
path4
path5

=========End of file===================================

I need to be able to programatically go throught a text file like the
above and put quotes around "DLL Compile Checker".

Thanks for any input.

-Ty

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Mon, 10 Jan 2005 08:32:27 GMT  
 Replace text in a text file
Hello Tyrone,

You can use Regular Expression (RegExp) Object. For more information, take
a look at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...
ml/vsobjRegExp.asp

Hope this helps.

Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

|X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
|Subject: Replace text in a text file

|
|I have some code that creates a batch file on the fly. I am having an
|issue with how the dir structures are being read. I need to find a way
|to search a text file and out quotes arround and dir or file that has
|spaces in it. Do anyone have any sample scripts vbscript's that would
|allow me to do this?  i.e.
|
|lets pretend that this is the file:
|=========begining of file=================
|c:\winnt\system32\vbchkw2k.exe c:\DLL Compile Checker
|path2
|path3
|path4
|path5
|
|=========End of file===================================
|
|I need to be able to programatically go throught a text file like the
|above and put quotes around "DLL Compile Checker".
|
|Thanks for any input.
|
|-Ty
|
|
|*** Sent via Developersdex http://www.developersdex.com ***
|Don't just participate in USENET...get rewarded for it!
|



Mon, 10 Jan 2005 14:40:25 GMT  
 Replace text in a text file
Could you post a slightly more extended example - with more "real"
paths?

--
Please respond in the newsgroup so everyone may benefit.
 http://www.bittnet.com/winremote
 http://www.bittnet.com/scripting


Quote:
> I have some code that creates a batch file on the fly. I am having an
> issue with how the dir structures are being read. I need to find a way
> to search a text file and out quotes arround and dir or file that has
> spaces in it. Do anyone have any sample scripts vbscript's that would
> allow me to do this?  i.e.

> lets pretend that this is the file:
> =========begining of file=================
> c:\winnt\system32\vbchkw2k.exe c:\DLL Compile Checker
> path2
> path3
> path4
> path5

> =========End of file===================================

> I need to be able to programatically go throught a text file like the
> above and put quotes around "DLL Compile Checker".

> Thanks for any input.

> -Ty

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Mon, 10 Jan 2005 21:07:49 GMT  
 Replace text in a text file
Perhaps it would be easiest just to add quotes to the beginning and
end of EVERY line.  After all, they won't cause any harm to the lines
that don't have spaces.

Set fso = CreateObject("Scripting.FileSystemObject")
Set outputFile = fso.CreateTextFile("c:\x.txt", True)
Set inputFile = fso.OpenTextFile("c:\y.txt")
Do While Not inputFile.AtEndOfStream
        strLine = inputFile.ReadLine
        outputFile.WriteLine(Chr(34) & strLine & Chr(34))
Loop

--Tom


Quote:
> I have some code that creates a batch file on the fly. I am having an
> issue with how the dir structures are being read. I need to find a way
> to search a text file and out quotes arround and dir or file that has
> spaces in it. Do anyone have any sample scripts vbscript's that would
> allow me to do this?  i.e.



Tue, 11 Jan 2005 00:17:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Replace text sequnec in text files : how ?

2. How to replace text string in text file

3. How to search a text file and replace text

4. Replace text in an existing text file?

5. Replace text in an existing text file?

6. Replace text in an existing text file?

7. How to search and replace text in text file

8. How to search and replace text in text file

9. How to search and replace text in text file

10. replacing text in a html-file and saving the changed file

11. Trying to search and replace a text file for a marked point in ht m file

12. replace text with text from another document

 

 
Powered by phpBB® Forum Software