Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
Find and replace a symbol in many t
Name: mikhail Date: November 8, 2007 at 16:17:10 Pacific OS: 2003 CPU/Ram: dual xeon 4gig ram Product: HP DL380
Comment:
Hi, Can someone help. I need a way to search through many text files to find an "Ã" and replace it with a "~". Or at least search through many text files and alert me if an à exists. Thanks in advance. Mike
Name: Mechanix2Go Date: November 8, 2007 at 17:31:54 Pacific
Reply:
@echo off setLocal EnableDelayedExpansion
del *.new
for /f "tokens=* delims= " %%a in ('dir/b *.txt') do ( set name=%%~Na for /f "tokens=* delims= " %%t in (%%a) do ( set str=%%t set str=!str:A=~! echo !str!>> !name!.new ) )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: Mechanix2Go Date: November 8, 2007 at 18:12:44 Pacific
Reply:
OOPS not so fast
That replaces 'a' as well as 'A'. Probably not what you want.
Needs more work.
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 3
Name: Razor2.3 Date: November 9, 2007 at 08:48:11 Pacific
Reply:
Here's a VBScript that'll do it:
Set oFSO = CreateObject("Scripting.FileSystemObject") Set oRegEx = New RegExp oRegEx.Global = True oRegEx.Pattern = InputBox("Replace what?", "Replace Text", "Ã") sRep = InputBox("With what?", "Substitute Text", "~")
If Len(oRegEx.Pattern) = 0 Or Len(sRep) = 0 Then _ WScript.Quit
For Each oFile In oFSO.GetFolder(".").Files If LCase(oFSO.GetExtensionName(oFile.Name)) = "txt" Then sFile = oFile.OpenAsTextStream().ReadAll oFile.OpenAsTextStream(2).Write oRegEx.Replace(sFile, sRep) End If Next WScript.Echo "Done"
Summary: What does it mean? I have a file which contains the name of various SQL scripts, like... T1.sql; inside these sql scripts i have a commit statement Do you mean that the file contains nothing but the ...
Summary: Need to find and replace string in a file using Batch program. It is a text file (but with a different extension simple text and there are blanks in the file). I am a Mainframe programmer and new to B...
Summary: find and replace "ultra" with extra in files and forders names ============================ hi i want a batch file that search for all files and forlders for find and replace "ultra" to "extra"...