Here is the vbscript, file name is "ReplaceText.vbs"
Option Explicit
Dim objFSO, objFile, objArgs, strFile, strText1, strText2, includeSubdirs, extension
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
If objArgs.Count <> 5 Then
WScript.Echo "Usage: ReplaceText.vbs ""Text String1"" ""Text String2"" ""Subdirectories"" ""file extension"" ""directory"""
WScript.Quit 1
End If
strText1 = objArgs(0)
strText2 = objArgs(1)
includeSubdirs = objArgs(2)
extension = objArgs(3)
strFile = objArgs(4)
If Left(extension, 1) = "." Then
extension = Mid(extension, 2)
End If
' Function to replace text in a file
Sub ReplaceTextInFile(filePath, searchText, replaceText)
Dim fileContent, updatedContent
Set objFile = objFSO.OpenTextFile(filePath, 1)
fileContent = objFile.ReadAll
objFile.Close
updatedContent = Replace(fileContent, searchText, replaceText)
Set objFile = objFSO.OpenTextFile(filePath, 2)
objFile.Write updatedContent
objFile.Close
End Sub
' Function to recursively process files in directories
Sub ProcessDirectory(directoryPath)
Dim folder, file, subfolder
Set folder = objFSO.GetFolder(directoryPath)
For Each file In folder.Files
If LCase(objFSO.GetExtensionName(file.Name)) = LCase(extension) Then
WScript.Echo "Processing " & file.Path
Call ReplaceTextInFile(file.Path, strText1, strText2)
End If
Next
If includeSubdirs = "true" Then
For Each subfolder In folder.SubFolders
Call ProcessDirectory(subfolder.Path)
Next
End If
End Sub
' Start processing
Call ProcessDirectory(strFile)
WScript.Echo "All files processed."
The parameters are as follows:
1) Text to replace
2) Replacement text
3) Look in subdirectories (true or false)
4) File extension (without ".")
5) Current directory (use "." for directory you are calling from... as in where you are making changes)
In Command prompt you could do the following command:
cscript //nologo ReplaceText.vbs " 0.0 null" " 0.0 null 1 1.0 null 1" "false" "mis" "."
or something similar, but be sure you know exactly what you need substituted.
alternatively you could write a batch to invoke many substitutions...
Say, a batch file named "subqmbthings.bat"
@echo off
echo Starting update...
:: Call ReplaceText.vbs for different replacements
cscript //nologo ReplaceText.vbs "\nAuthor" " Winter\nAuthor" "false" "properties" "."
cscript //nologo ReplaceText.vbs "Net1Summer/load.ini" "Net1Winter/load.ini" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$FurnitureSandbags_Round" "House$FurnitureSandbags_Round_W" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$FurnitureSandbag_Wall" "House$FurnitureSandbag_Wall_W" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$Tente-QG" "House$Tent_PyramidW_US" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$Crater100x6" "House$Crater100x6W" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$Tent_HQ_US" "House$Tent_HQW_US" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$filet_camouflage1" "House$Tent_HQW_US" "false" "mis" "."
cscript //nologo ReplaceText.vbs "House$AirdromeMaskingnet" "House$AirdromeMaskingnetW" "false" "mis" "."
echo All replacements completed.
that is just a sample that I used to make many substitutions for diorama "mis" files.