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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
floffy
Posts: 1
Joined: 14 Feb 2011 20:31

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

#1 Post by floffy » 14 Feb 2011 20:37

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

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

#2 Post by !k » 15 Feb 2011 03:27

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

Post Reply