Advertisement
2002C Files/ File Controls/ Input/ Output #13708

Find and Replace in multiple files

Find and replace text strings in multiple files within a directory. This allows for wilcards. Please Vote if you like it! :)

AI

AI 摘要: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

源代码
original-source
Dim strFind As String
 Dim strReplace As String
 Dim strDestination As String
 Dim strSource As String
 Dim strFilter
 
 strFind = "Hello" 'What to find
 strReplace = "Goodbye" 'What to replace it with
 strDestination = "c:\temp" 'Where to put the files once they have been modified
 strSource = "c:\output" 'Where to get the files
 strFilter = "*.txt" 'wildcards
 'verification complete
 Dim parse As String
 Dim hold As String
 'FIND AND REPLACE
 sdir = Dir(strSource & "\" & fMainForm.txtIncludeFilter)
 Do While sdir <> ""
 Open fMainForm.txtSource & "\" & sdir For Input As #1
 Do While Not EOF(1)
 Line Input #1, parse
 hold = hold & Replace(parse, fMainForm.txtReplace, fMainForm.txtFind)
 Loop
 
 Loop
 Open fMainForm.txtSource & "\" & sdir For Output As #1
 Print #1, hold
 Close #1
 hold = ""
 parse = ""
 sdir = Dir()
 Loop
原始评论 (3)
从 Wayback Machine 恢复