lundi 30 mars 2015

batch script to rename the data inside a text file

I have written a windows batch code to rename the folders and files recursively from V34 to 35 and so on..and but I need to change same V34 to 35 inside a text file,which is residing inside the files


Folder---file--text file(Inside the text file need to change the V34 content to V35)


Please find the below code which I have written and let me know for the changes



@echo off
setlocal disableDelayedExpansion
set "old=V34"
set "new=V35"
for /f "delims=" %%F in ('dir /b /s *. *.xslt ^| sort /r') do (
set "source=%%F"
set "oldname=%%~nxF"
setlocal enableDelayedExpansion
set "newname=!oldname:%old%=%new%!"
if /i "!newname!" neq "!oldname!" (
echo ren "!source!" "!newname!"
ren "!source!" "!newname!"
) )

for /f "delims=" %%i in (.*) do (
set "source=%%i"
setlocal enabledelayedexpansion
set "newname=!oldname:%old%=%new%!"
echo ren "!source!" "!newname!"
ren "!source!" "!newname!"
endlocal
)

endlocal

Aucun commentaire:

Enregistrer un commentaire