Quantcast
Channel: LAMPdocs: Linux, Apache, MySQL, PHP » Microsoft Windows
Viewing all articles
Browse latest Browse all 10

7zip Command Line: Basic Examples in Microsoft Windows

$
0
0

In this tutorial, we will deal only with the 7zip command line. 7zip is an application used for archiving files. It is similar to the widely used WinRAR program. Data is compressed according to the 7z format but it is capable of reading and writing several other formats as well. Users can access the program from the graphical interface; windows based shell integration or the command line.

7zip is a free of charge, open-source application. There are great options for programming backups, which we will see in a while. We shall be using a version which can be operated from the command line only. The advantage of this that program consists of a solitary executable file, which makes it easy to store in a flash drive.

There are two 7zip command line versions with 7zip. One is 7z.exe which uses external libraries and the other is a standalone file 7za.exe. The latter file contains built – in modules so it can be easily executed. This makes it extremely portable. The disadvantage of 7za.exe is that it compresses files according to 7z, gzip, bzip, ZIP, Z and tar formats. The 64 bit version supports large memory maps resulting in faster compression. Multi-threading is supported by each version.

  1. Download the version from the link below. http://sourceforge.net/projects/sevenzip/files/7-Zip/4.57/7za457.zip/download. The download consists of five files but only 7za.exe will be used. You can remove others if you want.
  2.  We will create a batch file that backups any folder. Type the following line in notepad.
  3. 7za.exe a cybernet.7z “C:UsersDellDesktop” This command creates a backup on desktop.  The location can be changed. Quotation marks are a must for a path with spaces. This example does not need any, but including them is a good habit. This command archives documents in a 7zip format. A 7 – Zip program will be needed to extract the contents.  The file can be saved in ZIP format as well by inserting zip in the command in place of 7z.
  4.  Go to the File tab and click on Save – As. Include the .BAT extension with the file name. Save the file in the exact same location as 7za.exe.
  5.  Run the batch file created in the above step. This creates a backup file in the same location as the batch file.
  6.  The batch file can be made to run involuntarily at a scheduled time. Use the Windows Scheduled Tasks Wizard to do this. The wizard can be run from the Control Panel.
  7.  It is always a good idea to insert the day and date in the backup. The program does this automatically if you follow the given steps. It is a very useful feature if you do not want your backups to be overwritten.
  8.  In Step 3, replace  cybernet.7z with %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%_cybernet.7z This gives the file the date of the current day.

The 7zip format compresses files to a large extent with a very high ratio. This reduces the size considerably and the disk space can be utilized for other purposes.  This is probably the biggest advantage of using the 7zip Command Line.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images