| | |
Text File ammendments
![]() |
•
•
Join Date: Feb 2005
Posts: 43
Reputation:
Solved Threads: 0
Hi
Can you help with amending this code, so it no longer looks at the boot ini, but will look at apx 200 separate texts files called "textfile1.txt" "textfile2.txt" etc etc consecutively for the line of text "Max100" and remove and replace with "max200"
This is a piece of code from a previous script that locates the boot.ini at c:\boot.ini and searches it for a dupe entry and removes it... any help would be appreciated
Thanks in advance
Can you help with amending this code, so it no longer looks at the boot ini, but will look at apx 200 separate texts files called "textfile1.txt" "textfile2.txt" etc etc consecutively for the line of text "Max100" and remove and replace with "max200"
This is a piece of code from a previous script that locates the boot.ini at c:\boot.ini and searches it for a dupe entry and removes it... any help would be appreciated
Thanks in advance
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
' /* Edit Boot.ini's Timeout Line */ call edit_bootini("c:\boot.ini") sub edit_bootini(bootpath) dim objFileSystem ' /* Get The File System Object */ set objFileSystem = createobject("Scripting.FileSystemObject") ' /* Get The file Object (For Properties) */ Set file = objFileSystem.GetFile(bootpath) ' /* Set The File's Attributes To Normal (not system, hidden, or read only) */ file.Attributes = 0 ' /* open bootpath (path to boot.ini, passed to sub from calling procedure) for reading */ Set objInputFile = objFileSystem.OpenTextFile(bootpath, 1) ' /* Read In the Entire file, and rip it apart by the newline character, storing it in an array */ inputData = Split(objInputFile.ReadAll, vbNewline) ' /* Set Our Counter Variable to 0 */ cnt = 0 ' /* For Each Element In our Array (for each line of the file) */ For each strData In inputData ' /* If the first 7 characters of this line of the file is "timeout" then */ if left(lcase(strData), 7) = "timeout" then ' /* change This Array's Value (This Line of the file) */ inputData(cnt) = "timeout=10" end if ' /* Add One to Our Counter Varaible */ cnt = cnt + 1 Next ' /* Close The File, No changes have been to the file, only to the array (variable) that holds the lines of the file */ objInputFile.Close ' /* Create An Object To overwrite the file indicated by bootpath */ Set objOutputFile = objFileSystem.CreateTextFile(bootpath, TRUE) ' /* For each element in our array (each line of the file, Modified from original) */ for each strData in inputData ' /* Write That Line to The File */ objOutputFile.WriteLine strData next ' /* Close the File (now saved with new changes) */ objOutputfile.Close ' /* Set The file To system and hidden attributes */ file.Attributes = 6 ' /* Clear The File System Object */ Set objFileSystem = Nothing
•
•
Join Date: Aug 2006
Posts: 20
Reputation:
Solved Threads: 1
This will do the iteration
Sub Modify_Trial()
Dim i
'/* Edit Boot.ini's Timeout Line */
'Call edit_bootini("c:\boot.ini")
For i = 1 To 100
Call edit_bootini("c:\textfile" & i & ".ini")
Next i
End Sub
Then in the new procedure
read the file
use the replace () function to change the required string and write the file
Sub Modify_Trial()
Dim i
'/* Edit Boot.ini's Timeout Line */
'Call edit_bootini("c:\boot.ini")
For i = 1 To 100
Call edit_bootini("c:\textfile" & i & ".ini")
Next i
End Sub
Then in the new procedure
read the file
use the replace () function to change the required string and write the file
•
•
Join Date: Feb 2005
Posts: 43
Reputation:
Solved Threads: 0
Hi,
Thanks for the advice, although I am a little confused?
I want to create a vbs script that will sit in the same directory as the "textfile1.txt" etc and once run it will open each text file consecutively and search the file for a reference to "max100" and then change that reference to "max200" and save the file and move on to the next file "textfile3.txt" etc etc and so on...
the bootini is no longer required but this code (with help from comatose) does contain a lot of the required features I need as it does very similar tasks. Basically what is required is a script to open up consecutive ".txt" files and change all references of "max100" to "max200"
any help is greatly appreciated
TIA
Thanks for the advice, although I am a little confused?
I want to create a vbs script that will sit in the same directory as the "textfile1.txt" etc and once run it will open each text file consecutively and search the file for a reference to "max100" and then change that reference to "max200" and save the file and move on to the next file "textfile3.txt" etc etc and so on...
the bootini is no longer required but this code (with help from comatose) does contain a lot of the required features I need as it does very similar tasks. Basically what is required is a script to open up consecutive ".txt" files and change all references of "max100" to "max200"
any help is greatly appreciated
TIA
![]() |
Similar Threads
- connect to text file database (Visual Basic 4 / 5 / 6)
- Output in the text file (C)
- Create stats from a text file (Java)
- Store Bluetooth remote address to a text file (C++)
- 10 line text file (Java)
- Read and write to an ASCII Text file (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Help with simple Array program
- Next Thread: Moving a file location
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





