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

    • The fact that memory in general is so high I have to take a loan out to build a computer now is just beyond stupid. Who's really to blame here? Low supply or high demand?
    • Display Driver Uninstaller (DDU) 18.1.5.5 by Razvan Serea Display Driver Uninstaller (DDU) is a utility for completely removing AMD/NVIDIA/INTEL graphics drivers and related packages from your system, attempting to eliminate all leftovers (including registry entries, folders and files, driver store). Though AMD/NVIDIA/INTEL drivers can usually be removed via the Windows Control Panel, this uninstaller tool was created for situations where standard uninstall fails, or when you need to fully remove NVIDIA or ATI graphics card drivers. After using this driver cleaner, your system will behave as though it’s the first time you’re installing a new driver—similar to a fresh Windows installation. As with all such tools, we recommend creating a restore point beforehand, allowing you to undo changes if issues arise. If you're having trouble installing an older or newer driver, try it—there are reports that it resolves such problems. Recommended usage: The tool can be used in Normal mode but for absolute stability when using DDU, Safemode is always the best. Make a backup or a system restore (but it should normally be pretty safe). It is best to exclude the DDU folder completely from any security software to avoid issues. You do NOT need to uninstall the driver prior using DDU. Requirements: .NET Framework 4.8 Compatible with Windows 7, 8, 8.1, 10, and 11 (32-bit or 64-bit) Note: Using on Insider Preview builds is at your own risk. Display Driver Uninstaller (DDU) 18.1.5.5 changelog: Added 'Reset to recommended' button for the Options. General fixes and improvements. Download: Display Driver Uninstaller (DDU) 18.1.5.5 | 1.7 MB (Freeware) Download: DDU Portable | 1.2 MB Links: Display Driver Uninstaller Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • WACUP 1.99.51.24568 Preview by Razvan Serea WACUP (WinAmp Community Update Project) is a modern, enhanced version of the classic Winamp music player, designed for better stability, performance, and compatibility. Built for Windows, WACUP retains the familiar Winamp interface while adding 64-bit support, bug fixes, and new features like improved audio format support, customizable skins, and optimized playlist management. Unlike bloated alternatives, WACUP focuses on lightweight performance and regular updates, making it the best choice for fans of the classic Winamp experience. Basically, if you miss the good old days of Winamp and want a modern upgrade that doesn’t mess things up, WACUP is for you! WACUP key features: Classic Winamp Feel – Keeps the familiar interface and functionality. Bug Fixes & Stability – Fixes old Winamp issues and improves performance. 64-Bit Support – Works better on modern systems. More Formats & Plugins – Supports additional audio formats and third-party plugins. Customizable UI – Skins and tweaks for a personalized look. Better Library Management – Improved playlists, media organization, and search. No Bloat – Focuses on performance without unnecessary extras. Regular Updates – Community-driven development with new features and fixes. WACUP 1.99.51.24568 Preview changelog: Fixed a deadlock seen from the recent crash reports when doing some of the drag + drop actions within the media library window Fixed a loading crash seen related to a problem with some of the artwork cache image files being restored which should now be better handled allowing for the bad image to be removed without it failing Fixed a deadlock seen from the recent crash reports when the internal metadata cache clearing is triggered which could block the main ui thread for too long with this now being moved to a background thread Fixed some performance issues with some of the methods related to determining artwork support which mainly affected the local library import / refresh (this is still slower for some compared to other players because there's more data & artwork aspects being checked for which means doing more processing on a single file despite the best of attempts to reduce duplicate / heavy processing where possible) Fixed a crash with the JTFE based missing files hotkey which no one seems to have used for an age for this to appear (maybe it's time to seriously consider stripping out features that aren't being used) Fixed how some of the file types which use extra information to reference their sub-songs is handled which was preventing some from being correctly resolved back to their base file (noticed fixing above) Fixed an issue with the handling of files with underscores in their filepath which wasn't being correctly handled causing some of the filename to be lost when shown as the title if title reading is delayed Fixed a few things that might be behind NotSoDirect not being stable for some setups though am still not certain that the changes done for this are going to fully resolve the problem from the crash reports Fixed the OS toast handling when there's no prior shortcut in the OS start menu to now create the shortcut (needed to allow the yes/no buttons for the new build / post-release toast) to be done as a hidden one so it's less likely to cause annoyance for those not wanting to see it whilst still allowing this less than ideal OS api implementation requirement to be met to avoid toasts without the needed buttons Fixed a regression when moving from taglib1 to taglib2 which broke some of the handling in place to allow for external programs to still access files when wacup has a held open cached instance of the file Everything else Updated cppwinrt (gen_win10shell.dll) to 3.0.260520.1 (26 May 2026) Updated libcurl (libcurl.dll) to 8.2.1 (24 Jun 2026) Updated Monkey's Audio (in_ape.dll) to 13.15 (28 Jun 2026) Updated mpg123 (mpg123.dll) to 1.33.6 (6 Jun 2026) Updated OpenSSL (libcurl.dll) to 3.5.7 (9 Jun 2026) Updated pugixml to 1.16 (16 Jun 2026) Updated taglib (tag2.dll) to 2.3.0 (11 May 2026) Updated vgmstream (in_vgmstream.dll) to the latest Git commit from 28 Jun 2026 Download: WACUP 64-bit | 9.6 MB (Freeware) Download: WACUP 32-bit View: WACUP Website | Screenshots Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • "over a thousand engineering hours" and started selling it but could not take a couple of minuets to send an AI email to ask permission. What an expensive lesson.
  • Recent Achievements

    • Week One Done
      Collagen Project earned a badge
      Week One Done
    • Reacting Well
      Wakeen1966 earned a badge
      Reacting Well
    • Rookie
      Almohandis went up a rank
      Rookie
    • Apprentice
      jahara21 went up a rank
      Apprentice
    • Reacting Well
      NovaEdgeX earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      526
    2. 2
      +Edouard
      265
    3. 3
      PsYcHoKiLLa
      146
    4. 4
      Steven P.
      99
    5. 5
      macoman
      55
  • Tell a friend

    Love Neowin? Tell a friend!