Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

7zip - Unzip files (7-zip) via cmd command

I try to unzip a file via CMD.

So I install WinZip (and its plugin to cmd), WinRAR, and 7-zip.

But when I try to execute a command via the CMD:

7z e myzip.zip

It gives the next error:

7z is not recognized as an internal or external command

In addition, I added the folder of 7-z to the environment variables (Properties--> advanced --> Environment Variables --> user variable --> choose path, and add C:Program Files7-Zip

What can be the reason?

I find the below solution for this.

while zipping in cmd or git bash - getting error like

 7z:command not found 

solution:

  • install 7z in your machine
  • set the path in Environment Variables -> User Variables
    • path -> edit -> new (add the path - C:ProgramFiles7-Zip) -> OK

Now to use 7z in git bash -

  • Go to C:Program Files7-Zip and copy 7z.exe file
  • Go to C:Program FilesGitusrin and paste 7z.exe file

Now, you will be able to use 7z with Git Bash

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Doing the following in a command prompt works for me, also adding to my User environment variables worked fine as well:

set PATH=%PATH%;C:Program Files7-Zip
echo %PATH%
7z

You should see as output (or something similar - as this is on my laptop running Windows 7):

C:UsersPhillip>set PATH=%PATH%;C:Program Files7-Zip

C:UsersPhillip>echo %PATH%
C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Wi
ndowssystem32;C:Windows;C:WindowsSystem32Wbem;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntel
WirelessCommon;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100To
olsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Fil
es (x86)QuickTimeQTSystem;C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Notepad+
+;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntelWirelessCommon;C:Program Files7-Zip

C:UsersPhillip>7z

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

<Commands>
  a: Add files to archive
  b: Benchmark
  d: Delete files from archive
  e: Extract files from archive (without using directory names)
  l: List contents of archive
  t: Test integrity of archive
  u: Update files to archive
  x: eXtract files with full paths
<Switches>
  -ai[r[-|0]]{@listfile|!wildcard}: Include archives
  -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
  -bd: Disable percentage indicator
  -i[r[-|0]]{@listfile|!wildcard}: Include filenames
  -m{Parameters}: set compression Method
  -o{Directory}: set Output directory
  -p{Password}: set Password
  -r[-|0]: Recurse subdirectories
  -scs{UTF-8 | WIN | DOS}: set charset for list files
  -sfx[{name}]: Create SFX archive
  -si[{name}]: read data from stdin
  -slt: show technical information for l (List) command
  -so: write data to stdout
  -ssc[-]: set sensitive case mode
  -ssw: compress shared files
  -t{Type}: Set type of archive
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
  -v{Size}[b|k|m|g]: Create volumes
  -w[{path}]: assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
  -y: assume Yes on all queries

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...