Page 1 of 1

Batch to Verify all files *.gz and delete the Bad GZ file

Posted: 14 Feb 2011 20:37
by floffy
I try this but can not exist to command on FOR DO

FOR %%F in (D:\dnews\BAG\TEMP\*.gz) DO (C:\dnews\UTL\gzip -d "%%F") | (IF %ERRORLEVEL% EQU 1 DEL /S "%%F")

>> FOR %%F in (D:\dnews\BAG\TEMP\*.gz) DO (C:\dnews\UTL\gzip -d "%%F") = take each *.GZ file un-archive them

if get a ERR Run this (IF %ERRORLEVEL% EQU 1 DEL /S "%%F")

The >%ERRORLEVEL% EQU 1 Mean if ERR can not unarchive DELL /S *.GZ

I do not find the err but understand not work

Re: Batch to Verify all files *.gz and delete the Bad GZ fil

Posted: 15 Feb 2011 03:27
by !k

Code: Select all

@echo off
FOR %%F in (*.gz) DO call :test "%%F"
goto :eof

:test
gzip -t %1
IF %ERRORLEVEL% EQU 1 DEL /q %1
goto :eof