PDA

View Full Version : Need Help For A Zip File


Cold
13-09-2007, 06:44 PM
Hi everybody, how is it? I need help about a program :sos:


I have a folder with some .Zip files, a lot of these are damaged so I need a program who automatically check CRC of every .zip file in this folder and then automatically deleted the CRC damaged files. Winzip doesn't make that kind of work, WinRar can only tell about damaged files but not help to delete it.

Please may someone help me to find a utility to make it right? :sos:

dosraider
13-09-2007, 07:02 PM
Thought 7Zip could do that.
http://www.7-zip.org/

Not 100% sure about the 'delete auto', never had to deal with that specific situation.
But at least in 7Zip you can select all the zipfiles in a folder to check them in one action.

Cold
13-09-2007, 10:41 PM
<div class='quotetop'>QUOTE(dosraider @ Sep 13 2007, 09:02 PM) 310709</div>
Thought 7Zip could do that.
http://www.7-zip.org/

Not 100% sure about the 'delete auto', never had to deal with that specific situation.
But at least in 7Zip you can select all the zipfiles in a folder to check them in one action.
[/b]


It verify all the files but doesn't allow to delete damaged zip

I would like not to delete it by myself :sos:

Scatty
14-09-2007, 02:26 AM
Why don't you like to delete the damaged ZIP's yourself? :huh:
Once the check is through, you would know which ones are damaged and all you have to do is to go to that folder and get rid of them... unless you're too lazy to be bothered.

dosraider
14-09-2007, 05:06 AM
Probably his downloaded pron pics, must be hundredthousands files.... :bleh:

Data
14-09-2007, 10:39 AM
write a script that tests in the error level/return code of testing the zip file

Problem solved

So9
14-09-2007, 11:43 AM
hi Alex Cold

in addition to data's hint
here's the script i use. runs only on win2k/xp (vista ?)


@ECHO OFF
REM Path to Commandlineversion
REM download 7za from http://downloads.sourceforge.net/sevenzip/7za442.zip
SET MYZIP="%ProgramFiles%\7zip\7za.exe"
SET MYLOG=logfile_.txt
ECHO. > %MYLOG%

REM Check for ZipExe
IF NOT EXIST %MYZIP% GOTO :NOEXE

REM ask User for basepath or use current
ECHO enter directory to scan [return for %CD%]
SET /P MYROOT=
IF (%1) EQU () SET MYROOT="%CD%"

FOR /R %MYROOT% %%f IN (*.zip) DO CALL :SCANIT "%%f"

GOTO :EOF

:SCANIT
ECHO Scanning %1
@CALL %MYZIP% t %1 > USELESS.$$$
SET /A ERROR=%ERRORLEVEL%

REM Log and Remove all
IF %ERROR% EQU 0 ECHO %1 OK >> %MYLOG%
IF %ERROR% NEQ 0 ECHO %1 CORRUPT >> %MYLOG%
IF %ERROR% NEQ 0 CALL :REMOVEIT %1

@DEL USELESS.$$$

GOTO :EOF

REM Uncomment DEL to remove corrupt files
:REMOVEIT
ECHO REMOVING %1
REM DEL %1
GOTO :EOF

:NOEXE
ECHO No ZipProgram found
GOTO :EOF

Cold
14-09-2007, 01:27 PM
<div class='quotetop'>QUOTE(So9 @ Sep 14 2007, 01:43 PM) 310893</div>
hi Alex Cold

in addition to data's hint
here's the script i use. runs only on win2k/xp (vista ?)


@ECHO OFF
REM Path to Commandlineversion
REM download 7za from http://downloads.sourceforge.net/sevenzip/7za442.zip
SET MYZIP="%ProgramFiles%\7zip\7za.exe"
SET MYLOG=logfile_.txt
ECHO. > %MYLOG%

REM Check for ZipExe
IF NOT EXIST %MYZIP% GOTO :NOEXE

REM ask User for basepath or use current
ECHO enter directory to scan [return for %CD%]
SET /P MYROOT=
IF (%1) EQU () SET MYROOT="%CD%"

FOR /R %MYROOT% %%f IN (*.zip) DO CALL :SCANIT "%%f"

GOTO :EOF

:SCANIT
ECHO Scanning %1
@CALL %MYZIP% t %1 > USELESS.$$$
SET /A ERROR=%ERRORLEVEL%

REM Log and Remove all
IF %ERROR% EQU 0 ECHO %1 OK >> %MYLOG%
IF %ERROR% NEQ 0 ECHO %1 CORRUPT >> %MYLOG%
IF %ERROR% NEQ 0 CALL :REMOVEIT %1

@DEL USELESS.$$$

GOTO :EOF

REM Uncomment DEL to remove corrupt files
:REMOVEIT
ECHO REMOVING %1
REM DEL %1
GOTO :EOF

:NOEXE
ECHO No ZipProgram found
GOTO :EOF

[/b]



Done. Thank you :brain:

So9
18-09-2007, 03:55 PM
this is an optimized version of the script with zip and rar support


@ECHO OFF
REM Init LogFile
SET MYLOG=logfile_%DATE:~-10%.txt
ECHO. > %MYLOG%

CALL :ADDLOG "--------------------------------------------------------------"
CALL :ADDLOG "Archive-Check 0.1**************************************"
CALL :ADDLOG "--------------------------------------------------------------"

REM Path to Commandlineversion
REM download 7za from http://downloads.sourceforge.net/sevenzip/7za442.zip
SET MYZIP="%ProgramFiles%\7-zip\7za.exe"
SET MYRAR="%ProgramFiles%\batchfiles\rar.exe"

REM Check for ZipExe
IF NOT EXIST %MYZIP% GOTO :NOEXE %MYZIP%
IF NOT EXIST %MYRAR% GOTO :NOEXE %MYRAR%

REM ask User for basepath or use current
ECHO enter directory to scan [return for %CD%]
SET MYROOT=
SET /P MYROOT=
IF (%MYROOT%) EQU () SET MYROOT="%CD%"

REM Ask for Scanmode (Fast=Open and List Contents/Deep=CRC)
ECHO Scanmode (F)ast or (D)eep [Deep]
SET /P SCANMODE=
IF /I (%SCANMODE%) EQU (f) (SET SCANMODE=Fast) ELSE (SET SCANMODE=Deep)

REM Set ScanSwitches
IF /I (%SCANMODE%) EQU (Deep) (
SET SWZIP=t
SET SWRAR=t
) ELSE (
SET SWZIP=l
SET SWRAR=l
)

REM Add Command-Switch
SET MYZIP=%MYZIP% %SWZIP%
SET MYRAR=%MYRAR% %SWRAR%

REM Here we go
CALL :ADDLOG "--------------------------------------------------------------"
CALL :ADDLOG "RootDir : %MYROOT%"
CALL :ADDLOG "Mode****: %SCANMODE%"
CALL :ADDLOG "RAREXE**: %MYRAR%"
CALL :ADDLOG "ZIPEXE**: %MYZIP%"
CALL :ADDLOG "--------------------------------------------------------------"
CALL :ADDLOG "Started : %TIME% / %DATE%"

REM SCAN ALL ZIP FILES
FOR /R %MYROOT% %%f IN (*.rar) DO CALL :SCANRAR "%%f"
FOR /R %MYROOT% %%f IN (*.zip) DO CALL :SCANZIP "%%f"

CALL :ADDLOG "Stopped : %TIME% / %DATE%"
IF EXIST USELESS.$$$ DEL USELESS.$$$
GOTO :EOF

REM ################################################## ##################
REM # Scan Archives
REM ################################################## ##################

:SCANZIP
@CALL %MYZIP% %1 > USELESS.$$$
SET /A ERROR=%ERRORLEVEL%

REM Log and Remove
IF %ERROR% EQU 0 CALL :ADDLOG "%1 OK"
IF %ERROR% NEQ 0 CALL :REMOVEIT %1
GOTO :EOF

:SCANRAR
@CALL %MYRAR% %1 > USELESS.$$$
SET /A ERROR=%ERRORLEVEL%

REM Log and Remove
IF %ERROR% EQU 0 CALL :ADDLOG "%1 OK"
IF %ERROR% NEQ 0 CALL :REMOVEIT %1
GOTO :EOF

REM ################################################## ##################
REM #Subfunktions
REM ################################################## ##################

:REMOVEIT
REM Uncomment DEL to remove corrupt files
CALL :ADDLOG "%1 CORRUPT"
REM DEL %1
GOTO :EOF

:NOEXE
ECHO %1 not found
GOTO :EOF

:ADDLOG
SET LOGOUT=%1
SET LOGOUT=%LOGOUT:"=%
ECHO %LOGOUT%
ECHO %LOGOUT% >> %MYLOG%
GOTO :EOF

Morrin
19-09-2007, 09:30 AM
Where do I put this script?

_r.u.s.s.
19-09-2007, 10:53 AM
.bat file?

So9
19-09-2007, 12:59 PM
hi

-create a file named "scanzips.cmd"
-leftclick on thee file and select "edit"
-paste the code
-doubleclick to run


bye
so9