Article View: comp.os.msdos.misc
Article #3933batch file to unzip each .ZIP file to its own directory (repost)
From: John Savage
Date: Wed, 22 Nov 1995 00:00
Date: Wed, 22 Nov 1995 00:00
50 lines
2540 bytes
2540 bytes
To explain this .bat script: 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 task for you: it will create a subdirectory
[within the current directory] named according to each of the .ZIP files
specified, 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 .*).
Of course, the pkunzip (or equivalent) executable needs to be in your PATH.
--
John Savage koala@sydney.dialix.com.au
Technical Details
Message-ID:
<48uv5t$k39$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,696b2ebc08f0432d,start X-Google-Attributes: gid10d683,public X-Google-Thread: f53ba,696b2ebc08f0432d,start X-Google-Attributes: gidf53ba,public X-Google-Thread: 111d31,696b2ebc08f0432d,start X-Google-Attributes: gid111d31,public X-Google-Thread: f71eb,696b2ebc08f0432d,start X-Google-Attributes: gidf71eb,public From: John Savage <koala@sydney.dialix.com.au> Subject: batch file to unzip each .ZIP file to its own directory (repost) Date: 1995/11/22 Message-ID: <48uv5t$k39$1@sydney.DIALix.oz.au> X-Deja-AN: 119919536 sender: koala@sydney.DIALix.oz.au organization: Gumleaf Smoke Signals Telegraph Co. newsgroups: comp.os.msdos.misc,comp.archives.msdos.d,comp.sys.ibm.pc.misc,aus.computers.ibm-pc