Software-BAT Tool Rename Tool

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值