How to compress files exist in one folder into seperated .7z files


Recommended Posts

Hello,

If I've a folder includes 10 .mp4 files.

I'd like to compress these 10 files using 7z, so I right click each file and do the process to add to archive.

The result is 10 compressed .7z files.

I do not want to compress all files into one big archive.

My question is how to comprress each file of these 10 .avi seperately once into .7z, or in other word in one step instead of re-do the process for 10 times?

If there is any other tool to do the job it will be good as well.

drag-and-drop onto batch file

http://dropcanvas.com/w7u6a/1


@echo off
rem 7z.exe path
set sevenzip=
if [%1]==[] echo file not found&pause&exit
if "%sevenzip%"=="" if exist "%ProgramFiles(x86)%\7-zip\7z.exe" set sevenzip=%ProgramFiles(x86)%\7-zip\7z.exe
if "%sevenzip%"=="" if exist "%ProgramFiles%\7-zip\7z.exe" set sevenzip=%ProgramFiles%\7-zip\7z.exe
if "%sevenzip%"=="" echo 7-zip not found&pause&exit
cd /d %~dp1||(echo ERROR&pause&exit)
echo %~dp1
echo %~x1
pause
for %%a in (*%~x1) do "%sevenzip%" a "%%~na.7z" "%%a"
pause
[/CODE]

OziZtl.jpg

PgO0Cl.jpg

This is the folder I want to compress files included into seperated files.

When I run the batch file I get this error that file not found, and when I press any key to continue I found it close itself.

Please help.

http://dropcanvas.com/w7u6a/3


@echo off
cd /d %~dp0
rem 7z.exe path
set sevenzip=
if "%sevenzip%"=="" if exist "%ProgramFiles(x86)%\7-zip\7z.exe" set sevenzip=%ProgramFiles(x86)%\7-zip\7z.exe
if "%sevenzip%"=="" if exist "%ProgramFiles%\7-zip\7z.exe" set sevenzip=%ProgramFiles%\7-zip\7z.exe
if "%sevenzip%"=="" echo 7-zip not found&pause&exit
set extension=.mp4
for %%a in (*%extension%) do "%sevenzip%" a "%%~na.7z" "%%a"
pause
[/CODE]

  • Like 1

http://dropcanvas.com/w7u6a/3


@echo off
cd /d %~dp0
rem 7z.exe path
set sevenzip=
if "%sevenzip%"=="" if exist "%ProgramFiles(x86)%\7-zip\7z.exe" set sevenzip=%ProgramFiles(x86)%\7-zip\7z.exe
if "%sevenzip%"=="" if exist "%ProgramFiles%\7-zip\7z.exe" set sevenzip=%ProgramFiles%\7-zip\7z.exe
if "%sevenzip%"=="" echo 7-zip not found&pause&exit
set extension=.mp4
for %%a in (*%extension%) do "%sevenzip%" a "%%~na.7z" "%%a"
pause
[/CODE]

Amazing you are the man and thanks a lot.

Please one last thing, please in this little script may you tell me what is the setting for the 7z to get the most maximum compression?

Thanks a lot.

In the future, just:

  1. Select the files or folders
  2. Right click (assuming you enabled 7z shell integration)
  3. Go to7-zip
  4. Click add to archive
  5. Change archive format to 7z
  6. Choose a file size in the section "split to volume, bytes"
  7. Press OK

Seeing as you want 10 files, just divide the total uncompressed file size in a Google search like this:

49.75 megabytes in bytes (Or whatever the size your file selection is)

Then just divide the number by 10 or whatever amount of files you want and enter this into "Split to volumes, bytes"

for %%a in (*%extension%) do "%sevenzip%" a "%%~na.7z" "%%a"

->

for %%a in (*%extension%) do "%sevenzip%" a -mx "%%~na.7z" "%%a"

have fun :)

what does -mx means?

In the future, just:

  1. Select the files or folders
  2. Right click (assuming you enabled 7z shell integration)
  3. Go to7-zip
  4. Click add to archive
  5. Change archive format to 7z
  6. Choose a file size in the section "split to volume, bytes"
  7. Press OK

Seeing as you want 10 files, just divide the total uncompressed file size in a Google search like this:

49.75 megabytes in bytes (Or whatever the size your file selection is)

Then just divide the number by 10 or whatever amount of files you want and enter this into "Split to volumes, bytes"

But I do not want to split anything at all and want to make it each file compressed seperated.

http://sevenzip.sour...d.htm#SevenZipX

-mx=5 normal compression

-mx=7 maximum compression

-mx=9 ultra compression

-mx is identical to -mx=9

edit:

i ran some tests

Path = mx5.7z

Method = LZMA2:24 BCJ

Physical Size = 6591553

Path = mx7.7z

Method = LZMA2:24m BCJ

Physical Size = 6567395

Path = mx9.7z

Method = LZMA2:24m LZMA:20 BCJ2

Physical Size = 6443632

Path = mx.7z

Method = LZMA2:24m LZMA:20 BCJ2

Physical Size = 6443632

  • Like 1

http://sevenzip.sour...d.htm#SevenZipX

-mx=5 normal compression

-mx=7 maximum compression

-mx=9 ultra compression

-mx is identical to -mx=9

thanks

Not sure I understand the point of this exercise.. Mp4 files rarely compress much at all, no matter what setting you tell your compression software to use.

I just did a test setting to ultra, and the 7z is actually bigger ;)

post-14624-0-28569400-1354972586.png

  • 6 years later...

Hello,

 

I know this thread is very old, but I must leave a reply because I find this is perfect solution for archiving multiple files to separate .7z archives!

 

I'm using Windows 10 Pro x64 and 7Zip tool.

 

First you need to download latest version of 7Zip: Download 7-Zip

 

I'm using script in this way and works perfectly:

 

1. Create blank .txt file

2. Enter this code in blank .txt file:

@echo off
cd /d %~dp0
rem 7z.exe path
set sevenzip=
if "%sevenzip%"=="" if exist "%ProgramFiles(x86)%\7-zip\7z.exe" set sevenzip=%ProgramFiles(x86)%\7-zip\7z.exe
if "%sevenzip%"=="" if exist "%ProgramFiles%\7-zip\7z.exe" set sevenzip=%ProgramFiles%\7-zip\7z.exe
if "%sevenzip%"=="" echo 7-zip not found&pause&exit
set extension=.pdf
for %%a in (*%extension%) do "%sevenzip%" a -mx "%%~na.7z" "%%a"
pause

3. In code change line set extension=. to extension of files that you want to add in archive

4. Save file as, for example separate-archive.bat (you must change extension from .txt to .bat) !!

5. Copy newly created separate-archive.bat file to folder where you want to archive multiple files in separate .7z archives

6. Double click on copied separate-archive.bat

7. Done! Dobule click on file opens a command line and files will be archived in separate .7z archives with Ultra compression

8. Delete separate-archive.bat file from folder where you done archiving

 

If you want different compression level you must change -mx command to desired compression level:

On 12/8/2012 at 10:39 AM, yxz said:

http://sevenzip.sour...d.htm#SevenZipX

-mx=5 normal compression

-mx=7 maximum compression

-mx=9 ultra compression

-mx is identical to -mx=9

for %%a in (*%extension%) do "%sevenzip%" a -mx "%%~na.7z" "%%a"

 

I'm using 7-Zip tool for years, but this is my first use in batch mode in command line.

 

I'm open for suggestions if you have some :)

 

Thank you very much!

 

Happy archiving!

 

-denahv

  • 1 month later...
  • Nick H. locked this topic
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I don't use Edge, I don't even use Windows these days as my main driver. Mac these days I use and Zen browser
    • Apple releases iOS 26.5.2 with dozens of security fixes for iPhone by Karthik Mudaliar Apple has released iOS 26.5.2 and iPadOS 26.5.2, which are security-only updates for the iPhone and the iPad. The update brings a bunch of security fixes for WebKit, WebRTC, WebKit Storage, WebKit Canvas, Web Extensions, libxslt, IOGPUFamily, and even the kernel. Some of the WebKit issues that were fixed could have allowed malicious web content to disclose sensitive user information, exfiltrate cross-origin data, crash Safari, or process restricted web content outside the browser sandbox. One notable WebKit Storage bug could let a malicious website to silently hijack clipboard data, according to Apple’s description. Other WebKit-related flaws involved memory corruption, use-after-free bugs, type confusion, out-of-bounds writes, permissions problems, and cross-origin data handling issues. The update also includes three kernel-related fixes. Apple says one of the flaws could let an app write kernel memory or cause unexpected system termination, while another may leak sensitive kernel state, and a third could corrupt kernel memory or terminate the system unexpectedly. Although Apple hasn't described them as remote web attacks, kernel bugs are still important to fix, as they can sometimes be chained with other flaws to escape app or browser restrictions. The updates are available for iPhone 11 and later, iPad Pro 12.9-inch 3rd generation and later, iPad Pro 11-inch 1st generation and later, iPad Air 3rd generation and later, iPad 8th generation and later, and iPad mini 5th generation and later. Similar security fixes also came with the latest update to macOS Tahoe 26.5.2, which Apple released on the same day. That overlap is not surprising, since Safari, WebKit, WebRTC, and other underlying components are shared across Apple’s platforms. Users are advised to update their devices sooner rather than later as these security fixes are crucial. iOS 26.5.2 can be installed from Settings > General > Software Update. Similarly, Mac users can find macOS Tahoe 26.5.2 through System Settings > General > Software Update.
    • Taken them long enough, that is one good thing. I still refuse to have a Whatsapp account, because it still need a phone number to have an account. don't want to give Meta my phone number
    • Good think I still have SDRAM and FP RAM sitting around.
    • Fitbit Charge 6 fitness tracker with Google apps is now at its lowest price with 47% off by Fiza Ali Amazon is currently offering the Fitbit Charge 6 fitness tracker at its all-time low price with a 47% discount. The device features an AMOLED touchscreen display protected by Corning Gorilla Glass 3 that should offer improved scratch resistance and durability. The Charge 6 is equipped with a range of sensors including an optical heart rate sensor, a 3-axis accelerometer, built-in GPS with GLONASS support, red and infrared sensors for SpO2 monitoring, a skin temperature sensor, an ambient light sensor, a vibration motor, NFC, and multipurpose electrical sensors compatible with the ECG and EDA Scan apps. Heart rate is recorded every second during exercise tracking and every five seconds during normal daily use. The device requires the Google Health app for setup and synchronisation. Furthermore, Bluetooth provides wireless connectivity for syncing and communication with devices running Apple iOS 16.4 or later and Android 11.0 or later. The tracker stores up to 7 days of minute-by-minute activity data and retains daily activity totals for the previous 30 days. In terms of water resistance, the Fitbit Charge 6 has a 5 ATM rating that should make it suitable for swimming and water activities. The tracker operates in temperatures ranging from 14°F to 113°F and at altitudes of up to 28,000 feet. Moreover, the included Infinity band is made from a flexible silicone material and features a loop-and-peg fastening. The small band fits wrists measuring 5.1 to 6.7 inches, while the large band fits wrists measuring 6.7 to 8.3 inches. Both small and large bands are included in the box. When it comes to battery performance, the Fitbit Charge 6 should deliver up to 7 days of battery life under typical usage conditions. Features such as the Always-On Display, built-in GPS, and SpO2 monitoring increase power consumption and may require more frequent charging. The rechargeable lithium-polymer battery should take approximately two hours to charge from empty to full. Fitbit Charge 6 Fitness Tracker with Google Apps: $85.45 (Amazon US) - 47% off Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Reacting Well
      NovaEdgeX earned a badge
      Reacting Well
    • Week One Done
      NovaEdgeX earned a badge
      Week One Done
    • One Year In
      BA the Curmudgeon earned a badge
      One Year In
    • Conversation Starter
      rosiecharles earned a badge
      Conversation Starter
    • First Post
      KMilenkoski1202 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      536
    2. 2
      +Edouard
      266
    3. 3
      PsYcHoKiLLa
      150
    4. 4
      Steven P.
      98
    5. 5
      macoman
      61
  • Tell a friend

    Love Neowin? Tell a friend!