In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use vbscript script to modify file content", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use vbscript script to modify file content" bar!
Use vbscript script to modify file contents, which is suitable for automated operations.
'create a new Replace.vbs script with the following contents. Enter three parameters when the program is running: find content, replace content, and file
The copy code is as follows:
Dim FileName, Find, ReplaceWith, FileContents, dFileContents
Find = WScript.Arguments (0)
ReplaceWith = WScript.Arguments (1)
FileName = WScript.Arguments (2)
'read the file
FileContents = GetFile (FileName)
'replace all find content in the file with replace content
DFileContents = replace (FileContents, Find, ReplaceWith, 1,-1,1)
'compare the source file with the replaced file
If dFileContents FileContents Then
'Save the replaced file
WriteFile FileName, dFileContents
Wscript.Echo "Replace done."
If Len (ReplaceWith) Len (Find) Then
'calculate the total number of substitutions
Wscript.Echo _
((Len (dFileContents)-Len (FileContents)) / (Len (ReplaceWith)-Len (Find) & _
"replacements."
End If
Else
Wscript.Echo "Searched string Not In the source file"
End If
'read the file
Function GetFile (FileName)
If FileName "" Then
Dim FS, FileStream
Set FS = CreateObject ("Scripting.FileSystemObject")
On error resume Next
Set FileStream = FS.OpenTextFile (FileName)
GetFile = FileStream.ReadAll
End If
End Function
'write a file
Function WriteFile (FileName, Contents)
Dim OutStream, FS
On error resume Next
Set FS = CreateObject ("Scripting.FileSystemObject")
Set OutStream = FS.OpenTextFile (FileName, 2, True)
OutStream.Write Contents
End Function
Thank you for your reading, the above is the content of "how to use vbscript script to modify file content", after the study of this article, I believe you have a deeper understanding of how to use vbscript script to modify file content, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.