Renaming file extension in batch
问题 I've got a few files like this: I'm wanting to change them all to *.gz This is the code I've written to try to change the file extensions: ren *.dat.gz.gz.gz.gz *.gz But this doesn't do anything. Thanks. 回答1: ren ????????.dat.gz.* ????????.gz or, if the .dat part is needed ren ????????.dat.gz.* ????????.dat.gz 回答2: Try this: @echo off setlocal enabledelayedexpansion for %%a in (*.gz) do ( set "file=%%a" set "file=!file:.gz.gz.gz=!" echo ren "%%~nxa" "!file!" ) Run it from the location of the