I tried searching previous questions but none worked, or I couldn't adapt them to my needs.
I want to write a script that asks for:
- folder
- criteria
- old string
- new string
And replace every file in the specified folder and subfolders (and force user to type one) with specific criteria (for example, it must be a ".cue" file), and:
- If the file is read-only, disable it.
- Search for specified old string in the file content and replace it with new string , and save changes in same file.
- If the file was read-only, enable it again.
I have this code so far, but I don't know what to do in the do
part:
@echo off
setLocal enableDELAYedexpansion
: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 ? "
echo modifying files...
for /r "%var2%" %%v in (%%files) do (
???
)
pause
goto START
:ERROR
echo type something!!
goto START
No comments:
Post a Comment