现在的位置: 首页 > 综合 > 正文

【原创】一个批量重命名一组文件扩展名的脚本代码

2014年11月02日 ⁄ 综合 ⁄ 共 582字 ⁄ 字号 评论关闭

一个朋友需要重命名大量文件的扩展名,花了十来分钟,帮他用个批处理实现,要求重命名成这样的形式:

abc.bmp -->abc.jpg

bcd.bmp -->bcd.jpg

cde.bmp -->cde.jpg

 

代码如下:

::*****************************************************************************

@echo off
@rem rename the extentens name of a set of files
@rem modifly here,expample as follows :format1---->format2 converted
set format1=bmp
set format2=jpg
::*****************************************************************************

setlocal ENABLEDELAYEDEXPANSION
set temp=
 for /f "tokens=1* delims=?" %%i in ('dir /b') do (
  set temp=%%i
  set temp=!temp:%format1%=%format2%!
  rename "%%i" "!temp!"
 )

cls&echo complete!
pause
exit /b 0

 

 

抱歉!评论已关闭.