UnZip/UnRar many files...

Dear fellow members, could you help me write the following .bat file:

I have a directory with 500+ .zip and .rar files
I want to run a batch file so that all files (each one my one):
1) uncompressed into C:\uncompressed into their very own directories (since some .zip/rar files have flat structure with no directories)
1b) And if any .zip/.rar files are found with, they should be uncompressed as well but in same directory and so on recursively
2) Only if uncompression was successful the source .zip/.rar file is to be moved to C:\delete
3) If uncompression was unsuccessful the file is to be moved into C:\investigate

Machine is Win XP Pro with PowerArchiver and WinRar at our disposal.

Thank you
InGearXAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

InteractiveMindCommented:
Hi.

I'm not sure what the command syntax is for using WinRAR and PowerArchive for this. But if you can figure it out, then just alter my code below to do it:

:====8<----[ FileName.bat ]----
@ECHO OFF
TITLE Decompress Utility

REM --------------------------------
SET uncompressDir=c:\uncompress
SET compressedDir=c:\compressedFiles
REM --------------------------------
CLS

ECHO.
ECHO Decompressing Zip files . . .
ECHO.

FOR /F "delims=" %%F in ('dir /s /b "%compressedDir%\*.zip"') do CALL :UNZIP "%%F"

CLS
ECHO.
ECHO Decompressing Rar files . . .
ECHO.

FOR /F "delims=" %%F in ('dir /s /b "%compressedDir%\*.rar"') do CALL :UNRAR "%%F"

TITLE Complete!
CLS
ECHO.
ECHO Complete!
ECHO.
PAUSE>NUL
TITLE Command Prompt
GOTO :EOF

:UNZIP
SET File=%~1
TITLE Decompressing: %~nx1

IF NOT EXIST "%uncompressedDir%\%~n1" @MD "%uncompressedDir%" >NUL

REM ** Change the following line:
UNZIP "%File%" "%uncompressedDir%" >NUL

EXIT /B

:UNRAR
SET File=%~1
TITLE Decompressing: %~nx1

IF NOT EXIST "%uncompressedDir%\%~n1" @MD "%uncompressedDir%" >NUL

REM ** Change the following line:
UNRAR "%File%" "%uncompressedDir%" >NUL

EXIT /B
:====8<----[ FileName.bat ]----


HTH  :)
>> IM
0
InteractiveMindCommented:
Sorry; there are two instances of this line:

IF NOT EXIST "%uncompressedDir%\%~n1" @MD "%uncompressedDir%" >NUL

please change them to:

IF NOT EXIST "%uncompressedDir%\%~n1" @MD "%uncompressedDir%\%~n1" >NUL


While I'm here.. All you need to do, is change the two middle lines here:

REM --------------------------------
SET uncompressDir=c:\uncompress
SET compressedDir=c:\compressedFiles
REM --------------------------------

So that they point to the correct directories. You also need to change these two lines:

UNZIP "%File%" "%uncompressedDir%" >NUL
UNRAR "%File%" "%uncompressedDir%" >NUL

So that they actually call the correct programs, and decompress the file "%File%". One more alteration that you need to make, is changing the output directory in both commands from:

"%uncompressedDir%"

to:

"%uncompressedDir%\%~n1"


Then that should work fine  ^_^
Regards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
InteractiveMindCommented:
InGearX ... Does this help?

>> IM
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

InteractiveMindCommented:
Thank you.  :-)
0
InGearXAuthor Commented:
Sorry, I was out, you deserve full credit, thank you very mcuh!
0
InteractiveMindCommented:
That's cool. :-)
Thank you for getting back to me in the end though  ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.