When we use keil IAR, etc, you can prepare a template, and then copy it directly. It become troublesome when you want to rename files, and even its content.
I select some code from Internet and write a bat file.
copy the red code below into a txt file, then change its extension to bat.OK. Double click!
@echo off
echo Name : Universal Rename Tool
echo Function: Change files name and replace string of files
echo Author : Code is From Internet. All rights belong to Original Author.
echo Modified by Jacob Lui
echo Version : v1.0
echo Contact : iamlvshijie@gmail.com
setlocal
echo "First Change Files Name:------------------------->"
set /p oldname=Old Name:
set /p newname=New Name:
set /p wildcard=Input general character folder name(default:"*”):
for /f "usebackq delims=" %%i in (`dir /s/b/a-d %wildcard%`) do (
setlocal enabledelayedexpansion
set var=%%~nxi
set "var=!var:%oldname%=%newname%!"
if not "%%~nxi"=="!var!" (
echo Processing: "%%i" =》 "!var!"
)
echo %%i |find "mutiren.bat" >nul || ren "%%i" "!var!" >nul
endlocal
)
echo "Second replace string in files ------------------>"
set tmep=replace_bak.tmp
:Begin
echo "Tpye extensions of files whose string to been replaced.Type 0 quit."
set /p FILETYPE=File Type:
::set FILETYPE=*.txt
if %FILETYPE%==0 goto End
set tmep=replace_bak.tmp
setlocal enabledelayedexpansion
for /r %%k in (%FILETYPE%) do (
cd.>"%tmep%"
for /f "tokens=1* delims=:" %%i in ('findstr /i /n .* "%%k"') do (
set str=%%j
if not "!str!"=="" set "str=!str:%oldname%=%newname%!"
>>"%tmep%" echo.!str!
)
move "%tmep%" "%%k"
)
goto Begin
:End
pause
endlocal
By Jacob