Solved batch code to find/replace in .txt

March 2, 2014 at 15:25:54
Specs: Windows 8
i want to change my user-name with sir name and i cant figure it out. i have tried a few things i have found on line but it added line numbers which made the type of text file i need un-usable

See More: batch code to find/replace in .txt

Report •


#1
March 3, 2014 at 05:54:05
Your msg doesn't tell me much.

If you have a script which doesn't work, post it and say what it does; or what it doesn't.

If you have no script, describe the requirement.

=====================
M2 Golden-Triangle


Report •

#2
March 3, 2014 at 07:57:48
i have a number of .pgn document from comeing from chess.com periodicaly, this text document has my chess.com user name and not my actual name, i would like a script that goes into the text document and replaces all the instances of my user name with my actual name

Report •

#3
March 3, 2014 at 09:28:56
✔ Best Answer
::====== script starts here ===============
::
:: realname.bat 2014-03-04 0:25:15.45
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
set S=%%a
set S=!S:username=Joe Smith!
echo.!S!
) >> NEWFILE
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

Related Solutions

#4
March 3, 2014 at 10:07:51
Sounds like standard text replace.
Powershell:
$userName = "drekie89"
$realName = "Mr. Drekie 89"
Get-ChildItem *.pgn | 
ForEach-Object { (Get-Content $_) -replace $userName, $realName | Out-File -Force $_.FullName }

How To Ask Questions The Smart Way

message edited by Razor2.3


Report •

#5
March 3, 2014 at 11:13:54
thank you that fixed my issues

Report •


Ask Question