7zip unable process zip files from a folder - 7zip

I have a powershell script that is using 7zip to extract backup file from a particular folder. It was working before with rar files but the backup file compression changed from rar to zip. I was thinking the command used would work with out no changes but I am facing unexpected problems.
The command in use is
`7z e -y -i!Backups\TempFolder\t\* \TempFolder\t\
Backups\tempfolder\t\ folder has 2 zip files that were generated this morning. When I ran that command the output is
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Processing archive: \TempFolder\t\Admin_Backup.bak.zip
No files to process
Processing archive: \TempFolder\t\spector_Backup.bak.zip
No files to process
Archives: 2
Files: 0
Size: 0
Compressed: 206848564
Could someone tell me why the e command supplied with -y is not extracting the files ? Also, I thought the generated zip files were corrupted but I extracted manually fine.

You need to use the option -o for providing the output folder. Also, you don't need the option -i for the input files. Try this:
7z e -y Backups\TempFolder\t\* -o\TempFolder\t\

Related

How to open an old .exe file to view it's (text) contents?

Look at this page: http://www.cde.ca.gov/ds/sd/sd/filesgrad.asp
Newer files are text files but older ones executables. How should one open them or do anything with them?
The exe files are self-extracting zip files.
You can open them with winrar, winzip, 7z, and others, such as command line unzip that you can get on most platforms.
$ unzip -t grad93.exe
Archive: grad93.exe
testing: GRAD93.DBF OK
No errors detected in compressed data of grad93.exe.

Zip folder created by shell script not opening

I am using the below script to zip the folder and it contents :-
cd /home/fs/Inbnd/
pwd
tar -cvf Image_test_new.zip Image
chmod 777 *
chown fusionc:staff *
The file image.zip is getting created successfully. But the file is not opening and showing an error :
Is there an error in the ststement I am using to zip?
tar -cvf makes a tar ball, not a zip archive. You can verify this in Linux, before trying to open it in Windows.
touch not_going_to_be_a_zip
tar -cvf not_really_a.zip not_going_to_be_a_zip
unzip not_really_a.zip
Archive: not_really_a.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of not_really_a.zip or
not_really_a.zip.zip, and cannot find not_really_a.zip.ZIP, period.
The zip utility does a good job at making zip archives.
touch will_be_a_zip
zip i_am_a.zip will_be_a_zip Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
unzip -t i_am_a.zip
Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
Note: unzip -t will test the archive only, make sure its okay before trying it in Windows.
If you cannot use the standard approach like zip/unzip and if you have JDK installed on your machine then you can use the jar utility from JDK's bin folder.
To zip a file
jar cvf zip_file_name.zip image.jpg
The only overhead is that it will add a META-INF folder with a file named MANIFEST.MF in it, which you can delete after extracting the zip file.
Try to use zip command instead of tar command.

Listing files without unzipping and selective unzip

We have several big sized zip files. Each of these zips contains excel file and a bunch of bmp images.
I was just wondering if 7-zip allows listing the content of the zip without unzipping it? And also if we can selectively unzip the excel file?
Currently, I use c# console program utilizing diagnostic process to execute 7z.exe. It would be nice not to unzip the entire thing.
For listing you can use the list command (l) to the 7zip.exe
7z l archive.zip
For selectively extracting files you can use different commands to the extract command. Something like:
7z e archive.zip -oc:\soft *.xls

How to zip a file using cmd line?

I want to zip a directory using the batch file command (Windows XP batch file).
For example, if I want to unzip a file means I can use the jar -xf file.zip(java) bat file command.
Like that I want a command line batch to zip a directory.
If you are using Ubuntu Linux:
Install zip
sudo apt-get install zip
Zip your folder:
zip -r {filename.zip} {foldername}
If you are using Microsoft Windows:
Windows does not come with a command-line zip program, despite Windows Explorer natively supporting Zip files since the Plus! pack for Windows 98.
I recommend the open-source 7-Zip utility which includes a command-line executable and supports many different archive file types, especially its own *.7z format which offers superior compression ratios to traditional (PKZIP) *.zip files:
Download 7-Zip from the 7-Zip home page
Add the path to 7z.exe to your PATH environment variable. See this QA:
How to set the path and environment variables in Windows
Open a new command-prompt window and use this command to create a PKZIP *.zip file:
7z a -tzip {yourfile.zip} {yourfolder}
Cross-platform Java:
If you have the Java JDK installed then you can use the jar utility to create Zip files, as *.jar files are essentially just renamed *.zip (PKZIP) files:
jar -cfM {yourfile.zip} {yourfolder}
Explanation:
* -c compress
* -f specify filename
* -M do not include a MANIFEST file
Yes, we can zip and unzip the file/folder using cmd. See the below command and simply you can copy past in cmd and change the directory and file name
To Zip/Compress File
powershell Compress-Archive D:\Build\FolderName D:\Build\FolderName.zip
To Unzip/Expand File
powershell expand-archive D:\Build\FileName.zip D:\deployments\FileName
You can use the following command:
zip -r nameoffile.zip directory
Hope this helps.
Windows 10 has tar command since 2018. It supports zip archive in default. You do not need to install any additional packages nor software.
tar.exe acvf yourfile.zip yourfolder
Compress-Archive in PowerShell does not support 2GB+ files.
The zip Package should be installed in system.
To Zip a File
zip <filename.zip> <file>
Example:
zip doc.zip doc.txt
To Unzip a File
unzip <filename.zip>
Example:
unzip mydata.zip
Zip the folder from cmd by running PowerShell:
powershell "Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::CreateFromDirectory('folder','archive.zip')"
Unzip:
powershell "Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('archive.zip','folder')"
Nothing listed here worked with me. This should be a very simple thing. I post my answer here, if anything because each time I search for "how to zip on the cmd window" I end up on this page, with no solution that works for me.
So here is the one that works with me: zip output_file input_files, as in the screenshot below.

Create an archive with current date and time in file name using 7z command line

Today I lost my whole Far Cry 3 save game suddenly. So now I want to backup it's save game folder automatically on a certain period of time using windows task scheduling.
I want to include date and time in archive file name.
Here is my command
C:\>"C:\Program Files\7-Zip\7z" a -r "D:\FC3\%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4% %TIME% Backup".7z "C:\ProgramData\Orbit\46"
For formatting purpose, I followed this question on superuser
I am getting log when executing this command
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive D:\FC3\24.02.2013 17:52:10.62 Backup.7z
Error:
7-Zip cannot open file
D:\FC3\24.02.2013 17:52:10.62 Backup.7z
The filename, directory name, or volume label syntax is incorrect.
System error: Unspecified error
If I use a simple file name like "D:\abc". It would work.
Please help. Where I am going wrong..?
I got the point
File Names can not have :
I fixed the code by replacing colon with .
C:\>"C:\Program Files\7-Zip\7z" a -r "D:\FC3\%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4% %TIME:~0,2%.%TIME:~3,2%.%TIME:~-5% Backup".7z "C:\ProgramData\Orbit\46"

Resources