Thread View: comp.os.msdos.misc
1 messages
1 total messages
Started by John Savage
Sat, 02 Sep 1995 00:00
Re: batch file to unzip each .ZIP file to its own directory
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads