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.
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.
ren ????????.dat.gz.* ????????.gz
or, if the .dat part is needed
ren ????????.dat.gz.* ????????.dat.gz
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 .gz files. Remove the Echo when the screen output looks right.
It works too:
@echo off
for /f %%a in ('dir /b /s *.gz') do (
for /f "delims=. tokens=1" %%b in ('echo/%%~na') do (ren "%%a" "%%b.gz")
)