how to uncompress *.xml.GZ files with bat

February 3, 2020 at 22:26:15
Specs: Windows 10
Hi,

can anyone please help with below batch script?
I have several files in a folder with extension as *.xml.GZ.

i need to prefix all the files with FIX, uncompressed these files and move the compressed into another folder.

e.g file script.xml.GZ after rename to be FIX_script.xml.GZ
and uncompress as FIX_script.xml


@echo off

set "dir=D:\test"
set "pfx=FIX_"

setlocal enabledelayedexpansion
for /r "%dir%" %%A in (*.xml.GZ) do (
set "xml=%%~nA"
if not "!xml:~0,13!"=="%pfx%" ren "%%A" "%pfx%%%~nxA"
)
for %%a in (*.GZ) do (
Call :UnZipFile "D:\temp\%%~na\" "D:\temp\oldfiles\%%~nxa"
)

pause


See More: how to uncompress *.xml.GZ files with bat

Reply ↓  Report •

#1
February 4, 2020 at 06:57:43
Something like this? please make a backup of D:\temp & D:\test as i deffinitly did not test this & i have no clue what your :UnZipFile function does.


@echo off&setlocal enabledelayedexpansion
pushd "D:\test"
for /f %%a in ('dir/A-D/b ^| findstr ".xml.GZ"') do (
set "lel=%%a"
copy "%%a" "D:\temp\FIX_%%a"
call :UnZipFile "D:\temp\FIX_%%a" "D:\temp\FIX_!lel:~0,-3!"
)
exit/b

i5-6600K[delid]@4.8GHz Core/4.6 Cache@1.456v | 2x8GB DDR4-3200MHzCL12-12-12-28-1@1.5v | Sapphire Nitro+ SE RX 590 8GB@1610Mhz core@1.13v/2236MHz


Reply ↓  Report •

#2
February 5, 2020 at 22:02:34
Hi,

the copy and prefix the file with FIX_ is working.

However, the unzip does not work. Is there another command that can be used to uncompress the files after the rename. ?
and if FIX_ already exist in the file name it should not add any prefix.

pls help.

message edited by akia


Reply ↓  Report •
Related Solutions


Ask Question