|
| |||||||||
| Tags: batchfiles, edit, files, script, vbscript |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Anyone have Script to edit multiple files?
Hi friends , Can anyone tell me how to write a script that will edit multiple text files? File can have extensions as *.htm, *.ini, and *.xml etc. etc. It will perform the actions such as finding or replacing the text words and adding or removing comments. I am regular user of this forum and know that I will get answer about it. Thank you in advance. |
|
#2
| ||||
| ||||
| Re: Anyone have Script to edit multiple files?
Hi, I have got on internet something which is helpful to you. You can try this whether it is working or not? You need to do steps as follow: 1.Open Notepad, paste the below script : @echo off REM — Prepare the Command Processor – SETLOCAL ENABLEEXTENSIONS SETLOCAL DISABLEDELAYEDEXPANSION ::BatchSubstitude – parses a File line by line and replaces a substring” ::syntax: BatchSubstitude.bat OldStr NewStr File :: OldStr [in] – string to be replaced :: NewStr [in] – string to replace with :: File [in] – file to be parsed if “%*”==”" findstr “^::” “%~f0″&GOTO:EOF for /f “tokens=1,* delims=]” %%A in (’”type %3|find /n /v “”"‘) do ( set “line=%%B” if defined line ( call set “line=echo.%%line:%~1=%~2%%” for /f “delims=” %%X in (’”echo.”%%line%%”"‘) do %%~X ) ELSE echo. ) 2. Save the file as “change.bat” The above script will parses a file line by line and will replaces a desired substring. 3. Open cmd prompt >> type the following command: c:\change.bat “text-to-replace” text-to-replace-with c:\FileToEdit.txt > c:\Edited_file.txt Reply me whether it is working or not? |
|
#3
| ||||
| ||||
| Re: Anyone have Script to edit multiple files?
Hi, you can check for the script which I have made. This will solve your problem. You can try it as you need a script to edit multiple files. I think batch file will be better solution for you. Try this script. It have the capability to replace all "ABC" in files *.html to "XYZ". Steps to Follow: Get a list of .html files. var str list ; lf -n "*.html" > $list File loop. while ($list <> "") do Read in the next file. var str file ; lex "1" $list > $file var str content ; cat $file > $content Replace "ABC" to "XYZ". sal "^ABC^" "XYZ" $coontent > null Write file back. echo $content > { echo $file } done |
|
#4
| |||
| |||
| Re: Anyone have Script to edit multiple files?
I don't know how to do this. But find something on internet regarding how to wtite script to edit multiple files? Look at it and check whether it is helping you or not? var str list ; lf -n "*.html" > $list while ($list <> "") do var str file ; lex "1" $list > $file var str content ; cat $file > $content sal "^ABC^" "XYZ" $content > null echo $content > { echo $file } |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Anyone have Script to edit multiple files?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create a php script to replace a string in multiple files | KADEEM | Software Development | 4 | 23-11-2009 05:09 PM |
| Script to create multiple groups from Excel file | Cezar Wilk | Active Directory | 2 | 15-10-2009 01:56 AM |
| How to copy multiple files to multiple destination at a time | Aaryn | Windows Software | 3 | 14-05-2009 11:25 AM |
| Edit Registry to Eliminate Driver Installation for Multiple IdenticalUSB Devices | kevincw01 | Windows XP Support | 4 | 22-08-2008 08:22 PM |
| Script to create multiple groups | Duncan | Active Directory | 3 | 19-08-2008 12:51 AM |