美文网首页
bat批处理:重命名图片名称,根据UserID命名。

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

作者: 张天择 | 来源:发表于2019-07-20 19:29 被阅读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执行。

    相关文章

      网友评论

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

          本文链接:https://www.haomeiwen.com/subject/acnulctx.html