I have over one hundred txt files, and in each file are words which need to be changed.
If anyone can help me fix this I would appreciate it.
Here is my script:
@echo off
set "Find=Earth"
set "Replace=World"
set "source=Folder1"
setlocal enableDelayedExpansion
(
for /F "tokens=1* delims=:" %%a in ('findstr /N "^" "%source%\*.txt"') do (
set "line=%%b"
if defined line set "line=!line:%Find%=%Replace%!"
echo(!line!
)
) > %source%\%%~nxa.txt.bak
I was trying with a test file to find the word Earth
and replace it with another word, or delete it completely.
document 1.txt
Earth
%~nxa.txt.bak
1. World
Somehow, I get a number and the output I get %~nxa.txt.bak
I did take a look around the site, and I did find a script that changes data, but it took too long to do so.