bat批处理:重命名图片名称,根据UserID命名。

2019-07-20  本文已影响0人  张天择

在D:\下有一个文件夹:D:\face,在这个文件夹下存放着一个照片文件夹:D:\face\1,一个存入学生UserID文本文件:D:\face\UserID.txt。

把D:\face\1  文件夹下的照片名批量以学生ID重新命名。

1,创建一个UserID.txt(存放UserID)

2,创建一个new.bat文件,代码如下

@echo on&setlocal enabledelayedexpansion

for /f "delims=U" %%a in ('cmd /u /c echo 唉') do set "tab=%%a"

cd /d "D:\face\1"

(for /f "delims=" %%a in ('echo ##^&echo ##^&dir /b/od *.png') do (

    set/p fn=

    if not "%%a"=="##" ( 

      for /f "tokens=1 delims=%tab%" %%b in ("!fn!") do echo ren "%%a" "%%b.png">>"D:\face\b.bat"

    )         

))<"D:\face\UserID.txt"

pause

3,创建一个空的b.bat

4,执行new.bat后b.bat文件应该如下

ren "weixin313.png.png" "1053.png"

ren "weixin932.png.png" "1054.png"

ren "weixin924.png.png" "1055.png"

..............................

5,将b.bat放入D:\face\1执行。

上一篇 下一篇

猜你喜欢

热点阅读