Guide:DDSopt/Batch Files/3 Compress-7z in folder

From Step Mods | Change The Game

REM The Vanilla Folders Archive batch file will automatically compress the folders with optimized textures in "Vanilla Optimized".
REM This step is done after the textures are optimized; details of the steps are in the DDSopt guide (https://stepmodifications.org/wiki/Guide:DDSopt)
REM The archive file names are the same as the names of the folders in the Vanilla Optimized directory (e.g., STD.7z).
REM If desired, the user can change these names after the optimization is completed.
REM For example, if a user prefers a single file with all of the HRDLC resources, the HRDLC1, HRDLC2, and HRDLC3 folders can be combined into a single folder prior to archiving.

REM The files are archived into non-solid 7zip archives.
REM The files are at the root of the 7zip archive to avoid an additional unnecessary subdirectory in the archive.
REM LZMA2 compression is used, and multiple CPU cores are used for archiving if they are available.

REM The resulting 7zip files will be in the working directory.
REM From here they can be copied or moved to the installer directory used by a mod manager (Wrye Bash or Mod Organizer).

REM There are two versions of this batch file
REM * one version for use when the directory containing the 7zip executable (7z.exe) is in the command path
REM * one version for use when 7z.exe is copied into the working folder.

REM It is preferable, since it saves additional steps in other processing, to have 7z.exe in the command path
REM However, some users will prefer not to do this.

REM this version of the batch file is used when 7x.exe is copied into the working folder.

REM these 2 lines should ensure that the correct working directory is found
@setlocal enableextensions
@cd /d "%~dp0"

echo off
echo.
echo The system says the Working Directory is   %cd%
echo This directory should include the "Vanilla Optimized" directory
echo If any of the above is incorrect terminate the processing and fix the problem
echo.


IF NOT EXIST "%cd%\Vanilla Optimized" echo The Vanilla Optimized directory is not in the working directory; fix this before proceeding
echo.
pause

echo on

cd "Vanilla Optimized"
for /D %%d in (*.*) do "%cd%\7z.exe" a -m0=lzma2  -mmt=4 -t7z  -ms=off "%%d.7z" ".\%%d\*" >nul
move *.7z ..\
cd ..