I am looking for the 7-zip command line call that is the equivalent to the explorer extension option of Add to "FolderName.zip":
I have tried:
& 7z C:\path\To\SecondAttempt, C:\path\to\SecondAttempt.zip
And I get the following
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
Command Line Error:
Unsupported command:
C:\path\to\SecondAttempt,
Does anyone know the command line equivalent of the explorer extension for 7-Zip?
The shell extension invokes 7zG.exe, a GUI utility that shows a nice GUI window if this is what you were looking for. Using SysInternal ProcMon it's possible to look up the command line used, basically:
& "C:\Program files\7-Zip\7zG.exe" a -tzip -slp- "a.zip" "file1.txt" "file2.txt"
The file list can be put into a file and its name is specified after # instead of the file names.
-slp- disables large page mode, and -slp enables compression speedup of large files
Fo 7Zip this should be the correct syntax
. .\7z.exe a C:\path\to\SecondAttempt.zip "C:\path\To\SecondAttempt"
But I would prefer to use directly .NET
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory("C:\path\To\SecondAttempt","C:\path\to\SecondAttempt.zip")
Related
I am attempting to write a command that calls 7-zip from the command line. My command is:
7z x z:\dev\archive.7z
Anytime I run this command in the command prompt, it acts like it's working, but when I navigate to the folder after the fact, the extracted files aren't there, although they are there if I run 7-zip from the contextual menu. Is there something I'm missing here?
If you don't specify a destination directory, 7z will extract files in your current directory.
As per the doc, to specify a target:
7z x archive.zip -oC:\path\to\target
Or use cd C:\path\to\target and then invoke your initial command.
In your case (from comments), what you want is:
7z x z:\dev\archive.7z -oz:\dev
This nice answer might help if you're confused with the options.
Try using the -spf switch
7z x z:\dev\archive.7z -spf
I am using the FCIV ( Microsoft File Checksum Integrity Verifier ) executable to automatically calculate checksums for certain files.
I want to invoke this executable within a powershell script. This is my snippet within Powershell.
& "Path to FCIV.exe" –add "Base Dir" -bp "Base Dir" -r –xml "Path to XML"
This commands basically recurses and calculates checksums for all files under "Base Dir" and then outputs into an XML file. I am able to execute this command on Powershell prompt. But when I add this line into a script and execute the script, I get this error.
–add\*
Error msg : The system cannot find the path specified.
Error code : 3
I have tried everything from adding FCIV to PATH environment variable as well as providing the whole path to files.
Any suggestions on how to overcome this?
I'm creating an zip file using 7zip from the command line during my build process. using a command like this:
7z.exe a -pPassword "..\sot.zip" .
This command works correctly and I'm able to see an encrypted file as expected. Now when I add the capability to encry0pte the headers
7z.exe a -mhe=on -pPassword "..\sot.zip" .
7z.exe a -mhe+ -pPassword "..\sot.zip" .
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive sot.zip
System error:
The parameter is incorrect.
I get "The parameter is incorrect." errors regardless of where I put them on the command line.
Is there a way to perform the encryption of headers from the command line.
-mhe is not supported in .zip files. For it to work, use .7z format
7z.exe a -mhe=on -pPassword "..\sot.7z"
I did this, and it did work:
7z.exe a -psecret -mhe=on C:\newfolder\a.7z "C:\folder1\back-this-up"
i have such problem. When i use command for 7zip:
7za a -t7z file.7z file.iso
i see in console dynamically changing output like this:
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive file.7z
Compressing file.iso 12%
When i redirect output to file with command:
7za a -t7z file.7z file.iso >> file.txt
Im just getting final message:
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive file.7z
Compressing file.iso
Everything is Ok
Why? I want all messages. What am i doing wrong?
it all is ok, I'm using exactly the same 7zip version under current stable debian 7.1 64bit.
7zip detects, stdout is assigned to terminal or not. when not to terminal, this in the background use option -bd , disable percentage indicator. developer assumes that you read log post factum, and do not analize output on the fly.
unfortunately it is not possible switch on percentages on the file. you can only switch off percentages on the screen.
what for you need % in log file.txt ?
While trying to extract zip files I get the error:
c:\path\name.zip is not RAR archive
No files to extract
My code is:
p.StartInfo.FileName = #"C:\Program Files\WinRAR\rar.exe";
p.StartInfo.Arguments = string.Format("x -o- {2} \"{0}\" * \"{1}\"\\ ",
szFN,
outFolder,
passWord == null ? "" : string.Format("-p\"{0}\"", passWord));
The GUI version can extract zip and 7z files.
Why doesn't this work? How can I extract zip and 7z files?
(NOTE: I have different source code for 7zip. I guess I can merge the two and only use the above when the file has a rar extension. But I don't like that solution.)
Free unrar.exe and console versionRar.exe of WinRAR support only RAR archive format. That is clearly described in second paragraph in manual for Rar.exe which is the text file Rar.txt in program files folder of WinRAR.
You need to use WinRar.exe instead which supports also other archive formats:
[path\winrar.exe] x [switches] [path to zip file] [files to extract, . for all files] [path folder to extract to]
Example:
"%ProgramFiles%\WinRAR\winrar.exe" x -ibck c:\file.zip *.* c:\folder\
The syntax, commands and switches for GUI version WinRAR.exe are listed and described in help of WinRAR. Click in menu Help on menu item Help topics, open on help tab Contents the item Command line mode and read the help pages listed under this item.
For example the switch -ibck supported only by WinRAR.exe but not by Rar.exe is for running the extraction in background which means GUI version of WinRAR makes the extraction minimized to an icon in Windows system tray.
rar.exe can indeed only unpack rar files. It's not at all the same as WinRAR.
For unpacking ZIP files in .NET, you might want to look at the DotNetZip library instead. It has a license compatible with commercial software, unlike CSharpZipLib.
If you need to support RAR as well, you can use UnRAR.dll with pinvoke:
http://www.rarlab.com/rar_add.htm
http://www.rarlab.com/rar/UnRARDLL.exe
Or this .NET unRAR libary:
http://www.chilkatsoft.com/rar-dotnet.asp
Perhaps this one for 7zip.
You can use either SevenZipSharp or DotNetZip Library in your Application!
But I will go for SevenZipSharp Lib as It supports all the archives supported by 7-Zip!
Both Source and Binary are available in the Links!
for /f "tokens=*" %G in ('dir /on /b "D:\BACKUP_DATI\EXCEL\OPER*.ZIP"') do "C:\Program Files\7-Zip\7z.exe" x "..\%G" –aoa
References to further reading:
7-Zip command line examples
FOR /D - Loop through directory