批量修改扩展名

来源:这里教程网 时间:2026-03-03 18:20:17 作者:

很多图书配备的源码都是txt格式,以前示例直接修改为SQL文件,方便编辑器直接打开

tree /f
ren *.txt *.sql
for /R %x in (*.txt) do ren "%x" *.sql

参考:

  • Recursively batch rename file extensions

    The following command will  rename files from one extension to another, in all subfolders:

    forfiles /S /M *.ext1 /C "cmd /c rename @file @fname.ext2"

    or

    FOR /R %f IN (*.kar) DO REN "%f" *.mid

    For example, if you want to rename all jpg files to png files, the command would be as below:

    forfiles /S /M *.jpg /C "cmd /c rename @file @fname.png"

    ---

    @ECHO OFF
    PUSHD .
    FOR /R %%d IN (.) DO (
    cd "%%d"
    IF EXIST *.old-extension (
    REN *.old-extension *.new-extension
    )
    )
    POPD

  • 相关推荐