Article View: comp.os.msdos.misc
Article #3968Re: batch file to unzip each .ZIP file to its own directory
From: John Savage
Date: Sat, 02 Sep 1995 00:00
Date: Sat, 02 Sep 1995 00:00
55 lines
2571 bytes
2571 bytes
I addressed this task some months back, but the solution I gave at that
time used the Un*x-like EXPR utility, so it was not pure MSDOS. Here is
a .BAT which does the job even better, and which uses DOS commands only.
To explain for new readers: you have downloaded a few .ZIP files from
some site, and need to unzip each and run them -- to test whether the
programs do what you hope and are worth keeping. Usually, this means
creating a handful of subdirectories, and unzipping one .ZIP into each.
This batch program does that job for you: it will create a subdirectory
[within the current directory] named according to each .ZIP file you
specify, and unzip each file into its own directory. For example, a
file named DC106F.ZIP will be unzipped into a subdirectory named DC106F
The .ZIP file extension can be omitted, and wildcards and drive letters
are allowed, though I have written it so that the drive letter need be
specified only once, and is assumed to apply to all following filenames.
Examples: UNZIP2D A:*.*
UNZIP2D A:DC*.* LIST*.* BATMNU21 READ131 SETEN*.*
UNZIP2D.BAT:
-----------
@echo off
if "%1" == "+" goto T
if "%1%2" == "" echo usage: unzip2d a:*.* b:file2.zip ...
set d=
for %%f in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do call c:unzip2d + %%f
goto X
:T
for %%i in (/%2) do set r=%%i
set c=%r%
for %%i in (/%2) do if not %%i==%r% set c=%%i
if %r% == %2 set r=.zip
if %c% == . goto W
if %c% == : set d=%3:
if not %c% == : set r=%r% %3%c%
call c:unzip2d + %r%
goto X
:W
if exist %d%%3.%r% mkdir %3
pkunzip %d%%3.%r% %3
:X
I have used this with DOS 5, but cannot say it will work for all versions.
It is a peculiarity with DOS that where you use a wildcard in the filename
then you must also specify the file extension (either as .zip or just .*).
--
John Savage koala@sydney.dialix.com.au
Technical Details
Message-ID:
<429ntc$pfk$1@sydney.DIALix.oz.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d683,8e43fa2cf8f44b02,start X-Google-Attributes: gid10d683,public X-Google-Thread: f53ba,8e43fa2cf8f44b02,start X-Google-Attributes: gidf53ba,public X-Google-Thread: f71eb,8e43fa2cf8f44b02,start X-Google-Attributes: gidf71eb,public From: koala@sydney.DIALix.oz.au (John Savage) Subject: Re: batch file to unzip each .ZIP file to its own directory Date: 1995/09/02 Message-ID: <429ntc$pfk$1@sydney.DIALix.oz.au> X-Deja-AN: 109362187 sender: koala@sydney.DIALix.oz.au organization: Gumleaf Smoke Signals Telegraph Company newsgroups: comp.os.msdos.misc,comp.sys.ibm.pc.misc,aus.computers.ibm-pc