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

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 There are multiple websites that describe how to do this; one example with menu pictures is
REM ( https://www.nextofwindows.com/how-to-addedit-environment-variables-in-windows-7/ )

REM The steps  to adding 7z.exe to the Path environmental variable are as follows:

REM First, determine where 7zip is installed on the computer. The directory name is 7-zip .
REM Right click on Computer on the desktop , or open the Control Panel and select "System".
REM Click "Advanced system settings"
REM On the resulting popup box click "Environmental Variables"
REM In the "System Variables" portion of the box, scroll and select "Path" then click "Edit"
REM At the end of what is there add a semicolon ";" then add the directory where 7x.exe is stored (e.g. "D:\7-zip")
REM Make sure not to have any spaces betrween the semicolon and the directory name.
REM When finished click OK, then click OK again, and click OK once more.

REM this version of the batch file is used when 7x.exe is in the Path

REM tests added 8/21/2013 to make sure the batch file is in the right folder and the folder structures are as expected

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 7z a -m0=lzma2  -mmt=4 -t7z  -ms=off "%%d.7z" ".\%%d\*" >nul
move *.7z ..\
cd ..