# Unzip command line tool



## MikeSwim07 (Apr 28, 2007)

Hey,

I have tried using unzip.exe from here, http://stahlforce.com/dev/index.php?tool=zipunzip , but you cannot chose where to unzip the files to.

Can someone help me find another one where you can chose where to unzip the files to?

Thanks


----------



## TheOutcaste (Aug 8, 2007)

http://www.7zip.com/

WinZip and WinRar also allow specifying the output folder.

Jerry


----------



## TheOutcaste (Aug 8, 2007)

Just downloaded unzip, it does support extracting to a folder. Just use the *-d* option
For usage, use *unzip -?*
*unzip /?* doesn't work

Jerry


----------



## MikeSwim07 (Apr 28, 2007)

Where is the command line tool? I only see the installer?


----------



## TheOutcaste (Aug 8, 2007)

For 7-zip you have to install it, then the command line tool is *7z.exe*

Doesn't look like you can just download the command line tool by itself.

Jerry


----------



## Gizzy (Aug 2, 2005)

Check out this link,

http://www.7-zip.org/download.html

There's a download for just the command line tool,

I never knew 7-zip had a .com site as well.


----------



## TheOutcaste (Aug 8, 2007)

Thanks for finding that Gizzy, I typed it in instead of using my bookmarks or Google.

I claim a Senior Moment

Jerry


----------



## Gizzy (Aug 2, 2005)

You're welcome,


----------



## MikeSwim07 (Apr 28, 2007)

I am having troubles with this. I cannot understand the syntax I need

I want to extract a zip file from the current directory to the C:\ drive


----------



## Gizzy (Aug 2, 2005)

Hello MikeSwim07, 

Using the command tool the syntax works like

```
7z e example.zip -oc:\
```
7z is the program,
e command is for extracting,
You want to extract example.zip,
-o Specifies which folder to extract to,
c:\ is the folder it's being extracted to,

Use x instead of e to keep the folder structure of the .zip contents (more like if you right click and extract a file)


```
7z x example.zip -oc:\
```
Make sure you're in the right folders in cmd,
If you're in the 7-zip folder then specify the directory to the .zip file c:\path\path\example.zip
If you're in the folder with the .zip file specify the directory to the 7-zip folder c:\path\path\7z

If you still don't get it just post back,
I'm not always that great with explaining things.


----------



## MikeSwim07 (Apr 28, 2007)

Thanks for the information, I got it working, thanks to you!

Can you explain the "x" more?

Thanks


----------



## Gizzy (Aug 2, 2005)

If there's folders in the archive and files in those folders then everything stays neat like in the archive with x,

But if e is used then everything in the archive will just be dumped into the new folder with no folder structure,

So if there's an archive with two folders each containing 5 pictures with the x command the folders will be extracted with the 5 pictures staying in each separate folder,

But with e the structure isn't preserved so the 10 images just get extracted to the folder you specified to extract to along with the 2 folders which are empty instead of containing the pictures so you'll have a folder with 10 pictures and 2 empty folders,

Make sense?


----------



## MikeSwim07 (Apr 28, 2007)

Oh I get it, 

Thanks


----------



## Gizzy (Aug 2, 2005)

You're welcome,

If you've got anymore questions just ask.


----------



## MikeSwim07 (Apr 28, 2007)

How do you make bold lines in cmd with a batch file

I tried some "==" signs but it doesn't make a bold line.

Thanks


----------



## Squashman (Apr 4, 2003)

Are you creating a menu?

You need to use the ALT keys to create those nice looking batch file menus.
http://http-server.carleton.ca/~dmcfet/menu.html


----------



## MikeSwim07 (Apr 28, 2007)

Oh, That is exactly what I needed.

Thank you sooo much!


----------



## MikeSwim07 (Apr 28, 2007)

Does this not work on vista?

I am pressing ALT and holding while I press the number, then I release ALT and the character doesn't show up.


----------



## Gizzy (Aug 2, 2005)

Are you using the num pad numbers?

The numbers across the top of the keyboard won't work.


----------



## MikeSwim07 (Apr 28, 2007)

Oh, My laptop doesn't have those side numbers


----------



## TheOutcaste (Aug 8, 2007)

Haven't tried on a laptop, but if you turn on the embedded Numeric keypad, and use those "number" keys, it might work.

Jerry


----------



## MikeSwim07 (Apr 28, 2007)

> embedded Numeric keypad


What's that? Do you mean the on-screen keyboard?

I also have a desktop which I use more often so this really isn't urgent


----------



## Gizzy (Aug 2, 2005)

I have a laptop and it doesn't have that side part but if I hold down a special key (on my laptop "fn") then I can use a different set of keys that work as the num pad (you can see the numbers in blue on the keys with the letters on my laptop)

Num lock also works so I don't have to hold fn.


----------



## TheOutcaste (Aug 8, 2007)

Most laptops have an embedded numberic key pad, numbers are usually on the keycaps. On my old Toshiba, it was turned on by FN+F11

```
789 = 789
uio = 456
jkl = 123
```


----------



## MikeSwim07 (Apr 28, 2007)

oooh I see it now. The ones on my keyboard are surrounded by little boxes. 

Lemme test it out

£]&#9508; cool


----------



## Squashman (Apr 4, 2003)

I can't find the Character Map in Vista.


----------



## Gizzy (Aug 2, 2005)

http://windowshelp.microsoft.com/Windows/en-us/help/e3dce7ff-c6f1-4da0-8904-cdf8761d1dc41033.mspx

Open Character Map by clicking the Start button , clicking All Programs, clicking Accessories, clicking System Tools, and then clicking Character Map.


----------



## Squashman (Apr 4, 2003)

Why do I bother trying to find things in vista.
You can just type Character map in the search box off of the start button and it will open it.


----------



## TheOutcaste (Aug 8, 2007)

MikeSwim07 said:


> How do you make bold lines in cmd with a batch file


Getting back to this.
The capability is there in the Console API, but you'd have to write your own routines to use it. http://en.wikipedia.org/wiki/ANSI_escape_code has more info.

You can use PowerShell to output bold/colored text.

It can be called from a batch file, but takes a second or two to load, so for a Menu best to create a script for the whole thing then call PowerShell to do it.

Other Options:

With XP you can still use the ansi.sys driver in command.com. Doesn't work in cmd.exe, so you are limited to what command.com can do, which is quite limited.
This doesn't work in Vista.

You can use Batchman or EKKO, at least with XP
Links to download them are here:http://www.robvanderwoude.com/ansi.html#AnsiCom

I tried them both in Vista running in Virtual PC, and the positioning was off -- don't know if this is because it was in VirtualPC, or because it's Vista, so you might get it to work under Vista.
You'd need to have batchman.com or ekko.com on all systems that you'd use this on of course.

Some issues with XP:
It only outputs lines that are 80 characters in length. You can have your windows set wider, but it won't print. The background color will be extended the full width.
It drastically slows it down though.

The first time Batchman is run it will clear the screen, so anything echoed to the screen earlier in the file will be lost.

The screen shot shows the results of this command (space after the A):
"*Batchman CECHO C xyh, A *"
where x and y are incremented by a loop. Then I outputted a 100 character line.
The command prompt is set to 120 wide, 50 high.

HTH

Jerry


----------



## Squashman (Apr 4, 2003)

You can also use SFK to echo words in color.


----------



## MikeSwim07 (Apr 28, 2007)

Thanks for the links.

I made a pretty nice menu (to me at least) with this link posted above,

http://http-server.carleton.ca/~dmcfet/menu.html


----------



## MikeSwim07 (Apr 28, 2007)

I have another question.

How do the commands in xp and vista differ? If I was making a batch file for an xp and a vista, how would they need to be different?

Thanks


----------



## TheOutcaste (Aug 8, 2007)

For XP and Vista both you'll need to scrounge up a copy of *choice.com*, as neither comes with that program anymore.

What I use is *Set /p* and a *goto* line. You need to account for them just pressing enter though, either assign a default, or ask again:

```
:_Menu
CLS
:: display menu
Set /p response="Enter your choice"
If [%response%]==[] Set response=1 (<= or goto error)
If %response% GEQ 1 If %response% LEQ 9 Goto _Menu%response%
:error
Echo. "Please enter a number between 1 and 9 only
:: Give them time to read the error
Ping 127.0.0.1 -n 5 >null
Goto _Menu
:_Menu1
:: Code for response of 1
:_Menu2
:: Code for response of 2
:_Menu3
:: Code for response of 3
:_Menu9
:: Code for response of 9
```
The trick here is you make the response part of the goto call. You just have to make sure you have a valid response. You can mix numbers and letters, but keep in mind that the comparisons are string comparisons, so *9* is less than *A* but *10* is greater than *A*.
This means if you change the 9 in the above to a 10, and the user types any single letter, the goto will fail, and end the batch file with a label not found error.
Easy fix for that is to check just the 1st character of the response using *set response=%response:~0,1%* and use letters if you need more than 9 choices (10 if you start with 0)
Or you can use separate If statements for each choice.

I'd totally forgot that *sfk* could echo colors. I'm surprised it doesn't have grey or white as choices though.
There is a workaround though; use *sfk color white* for bright white and *sfk color grey* to return to the default grey color. This does not change the color of lines already printed, only lines printed after the command. Combined with *sfk echo -noline* being able to suppress the CR\LF, it works almost as if it had those color options.

HTH

Jerry


----------



## MikeSwim07 (Apr 28, 2007)

So If I made a batch file on xp without choice.com, I could just as well run it on vista?


----------



## Squashman (Apr 4, 2003)

http://blogs.techrepublic.com.com/window-on-windows/?p=682


----------



## TheOutcaste (Aug 8, 2007)

Didn't think it was _that_ late when I posted. I opened a Command Prompt in Vista to double check, and typed (at least thought I'd typed) *choice /?* and got the usual error for a missing file:
'_filename here_' is not recognized as an internal or external command,
operable program or batch file.

I must have typed *chioce* or something similar by mistake and didn't notice


MikeSwim07 said:


> So If I made a batch file on xp without choice.com, I could just as well run it on vista?


Should work just fine.
The command line options for the Vista version of Choice are slightly different than the ones with choice.com (Win9x version) or choice.exe (WinNT version), so if you use choice, you'd have to check which OS the file is running under and use the correct syntax.

Tried copying the Vista *Choice.exe* to XP, and was told it's not a valid Win32 application, and then got an Access Denied message.

Choice.exe from the WinNT 3.5 resource kit seems to be better to use vs choice.com from Win9x. Running choice /? seems to take longer with the .com version.

It can be downloaded from here:
ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt35/i386/
Download the i386.exe file, place it in it's own folder and double click. That will extract the files, which are compressed.
You then need to use expand /R to expand the files you want.

HTH

Jerry


----------



## MikeSwim07 (Apr 28, 2007)

So If I use set instead of choice, there shouldn't be a problem, right?


----------



## TheOutcaste (Aug 8, 2007)

Right.

If you use the *goto%var%* trick, just be sure to test responses thoroughly, as the user is not limited in the number of characters they can enter, and string comparisons to check for a valid response can sometimes fool you.
*BADDATA* is greater than *A* and less than *C*, but is not the same as *B*

Jerry


----------



## MikeSwim07 (Apr 28, 2007)

I use like 

if %mainscreen%==1 goto lala

I don't really understand error levels, which is why I don't use them.


----------

