I have a new task to do a batch job to replace all subfolders's contents.lst files
Here is the example:
C:\level1\level2\level3
\level3a\level4
\level4a\level5
\level3b
Now the requirement is that under level2 folder, there is a contents.lst file which mainly display the list of files and folders under level2
same as level3 subfolder, level3a, level3b... level4, level4a, level5, they all have a contents.lst files
Now I would like to replace all these contents.lst files under different subfolders after level2
the content I like to replace as below code:
Code: Select all
@echo off
set optn=T582-08878-0101
set nptn=T592-08917-0100
@echo off &setlocal
set "search=%optn%"
set "replace=%nptn%"
set "textfile=contents.lst"
set "newfile=indesnew.txt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
echo(!line!
endlocal
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
Now question will be how we can have a batch script to do them all in one script, instead of doing one level as the above code did...
Thanks