Script for modifying file content in specified files

Solution 1:

Use FOR /F with DIR /B /S /A-D-R to get files that don't have the read only flag set.

Then use any of several published methods to modify a text file. I prefer to use a hybrid JScript/batch utility called REPL.BAT that performs a regex search and replace on stdin and writes the result to stdout. It is pure native script that runs on any modern Windows machine from XP onward - no 3rd party executable required. Full documentation is embedded within the script.

The L option causes a literal search, and the V option gets the search and replace values from variables instead of from string literals.

Assuming REPL.BAT in your current folder, or better yet, somewhere within your path:

@echo off
setlocal

:START
set "var2="
set /P var2="type folder "

if "%var2%"=="" goto ERROR

set /p old="old string ? "
set /p new="new string ? "
set /p files="what criteria ? "

for /f "delims=" %%F in ('dir /b /s /a-d-r "%var2%\%files%" 2^>nul') do (
  echo modifying %%F
  type "%%F" | repl old new lv >"%%F.new"
  move /y "%%F.new" "%%F" >nul
)

pause

exit /b

:ERROR
echo type something!!
goto START