Is it possible to write a script that will read... 
Author Message
 Is it possible to write a script that will read...

Is it possible to write a script that will read through another script
file (VBScript), search for a character string (Search for the
word "joe" in any capacity), then replace that value with "jane"?

This would be very useful if possible.  I am writing a template now
that I will use to create scripts for 20 sites with over 100 users each
and would like a tool to help out.

Thanks to anyone who can help!

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Sun, 16 Dec 2001 03:00:00 GMT  
 Is it possible to write a script that will read...
There are DOS command-line utilities to do this very thing.  You could
probably find some on download.com or filepile.com, or any of the other
freeware/shareware collections on the Web.

                                        Chick

Quote:

>Is it possible to write a script that will read through another script
>file (VBScript), search for a character string (Search for the
>word "joe" in any capacity), then replace that value with "jane"?



Mon, 17 Dec 2001 03:00:00 GMT  
 Is it possible to write a script that will read...
Sure...

See the docs for the FileSystemObject and the vbscript Replace function.

For each file, you'll use OpenTextFile twice, once (ForReading) to use the
ReadAll method to read the file in as one big text string, and then again
(ForWriting) to Write the modified string back to the file.  In between, you'll
use the vbscript Replace function to replace all ocurrences of "joe" with
"jane".

--
Michael Harris


| Is it possible to write a script that will read through another script
| file (VBScript), search for a character string (Search for the
| word "joe" in any capacity), then replace that value with "jane"?
|
| This would be very useful if possible.  I am writing a template now
| that I will use to create scripts for 20 sites with over 100 users each
| and would like a tool to help out.
|
| Thanks to anyone who can help!
|
|
| Sent via Deja.com http://www.deja.com/
| Share what you know. Learn what you don't.



Mon, 17 Dec 2001 03:00:00 GMT  
 Is it possible to write a script that will read...
Thanks very much!



Quote:
> Sure...

> See the docs for the FileSystemObject and the vbscript Replace
function.

> For each file, you'll use OpenTextFile twice, once (ForReading) to
use the
> ReadAll method to read the file in as one big text string, and then
again
> (ForWriting) to Write the modified string back to the file.  In
between, you'll
> use the vbscript Replace function to replace all ocurrences of "joe"
with
> "jane".

> --
> Michael Harris



> | Is it possible to write a script that will read through another
script
> | file (VBScript), search for a character string (Search for the
> | word "joe" in any capacity), then replace that value with "jane"?
> |
> | This would be very useful if possible.  I am writing a template now
> | that I will use to create scripts for 20 sites with over 100 users
each
> | and would like a tool to help out.
> |
> | Thanks to anyone who can help!
> |
> |
> | Sent via Deja.com http://www.deja.com/
> | Share what you know. Learn what you don't.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Tue, 18 Dec 2001 03:00:00 GMT  
 Is it possible to write a script that will read...
The script:

'---------------------------------------------------------------------
'--                       1999 ? Pablo Almunia Sanz
'---------------------------------------------------------------------
'--
'--     Program : FileReplace.vbs
'--      Sintax : wscript|cscript FileReplace.vbs <FileName> <OldText>
<NewText>
'--       Notes : With multiples files use this sintax in a Command Window:
'--               FOR %A in (<wildcard>) DO cscript filereplace.vbs %A
<OldText> <NewText>
'--   Programer : Pablo Almunia Sanz
'--        Date : 07/02/1999
'--     Version : 1.0
'--
'---------------------------------------------------------------------

'---------------------------------------------------------------------
'-- Main
'---------------------------------------------------------------------

If WScript.Arguments.Count <> 3 Then
 Call ShowUsage
 WScript.Quit 1
End If
cTexto = FileToStr( WScript.Arguments(0) )
StrToFile WScript.Arguments(0), Replace( cTexto, WScript.Arguments(1),
WScript.Arguments(2), 1, -1, vbTextCompare )

'---------------------------------------------------------------------
'-- FileToStr - Read a File and return its content as string
'---------------------------------------------------------------------
Function FileToStr( cFile )
 Set oFile = CreateObject("Scripting.FileSystemObject").OpenTextFile( cFile,
1 )
 FileToStr = oFile.ReadAll
 oFile.Close
End Function

'---------------------------------------------------------------------
'-- StrToFile - Write a String into a File
'---------------------------------------------------------------------
Sub StrToFile( cFile, cVar )
 Set oFile =
reateObject("Scripting.FileSystemObject").CreateTextFile( cFile )
 oFile.Write cVar
 oFile.Close
End Sub

'---------------------------------------------------------------------
'-- ShowUseg - Show the sintax of this script
'---------------------------------------------------------------------
Sub ShowUsage
 WScript.Echo "Sintax: wscript|cscript FileReplace.vbs <FileName> <OldText>
<NewText>"
End Sub

'----------------------------
'-- End of FileReplace.vbs --
'----------------------------



Tue, 18 Dec 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. script i am writing

2. need a script willing to pay

3. Writing a VBS file which reads and writes to the registry

4. a procedure I am writing for using with kshow

5. Am I writing over something ?

6. Possible Possible ASP Scripting Enhancements: compilation, queuing, resident programs

7. ANSWER TO WILLS

8. read registry possible with javascript?

9. Is it possible to read Excel from ASP

10. Write Script Tag using Document.Write

11. Is it possible to read from the registry?

12. Possible to Read NT logon via Vbscript?

 

 
Powered by phpBB® Forum Software