September 21, 2015

Compressing each folder with 7zip command line tool

If you have a lots of folder that you want to compressed, whether to save space or simply to upload to the web, compressing each of the folder individually can consume a lot of time.
However, you can simplify the process with the powerful 7zip compressor.
to do it,
step 1 - Open 'Run', or simply press the Windows Log on your keyboard and R. (Win Key+R).
Step 2 - Type CMD and press enter.
step 3 - Navigate to your folder location with the command CD then press enter.

For an easier method to directly open your folder in Command Prompt,
Simply presss the Shift key and right-click on your folder. A new link, 'Open command window here' will appear. Just click it, and the current directory of the CMD is that folder.
Next, start the compressing process with the following command;
FOR /D %d in (*.*) DO "%ProgramFiles(x86)%\7-zip\7z.exe" a -mx "%d.7z" "%d"
Use the following command if it give you error about the missing 7z.exe.
FOR /D %d in (*.*) DO "%ProgramFiles%\7-zip\7z.exe" a -mx "%d.7z" "%d"
It will start compressing your folder with the highest compression setting, Ultra.