我有一个替换文本文件中特定字符串的功能。这对于特定文件(test.conf)很好,没有任何问题。但是现在我正在寻找一种方法来检查目录中此字符串的每个文件。有没有一种方法可以检查目录中的所有文件,并找到并替换每个文件中的字符串?我不太确定如何使用“每个文件”功能。
Set objFile = objFSO.OpenTextFile(operations & "\test.conf",ForReading)
strText = objFile.ReadAll
objFile.Close
strText = Replace(strText,"$$username:$$",username)
Set objFile = objFSO.OpenTextFile(operations & "\test.conf",ForWriting)
objFile.WriteLine strText
objFile.Close
这是我对特定文件“ test.conf”的解决方案。
但是此文件夹中可能包含更多带有$$username:$$
字符串的文件。
示例:
\FOLDER\test.conf \FOLDER\abc.conf \FOLDER\def.conf ...