Created
January 17, 2024 01:46
-
-
Save milnak/c5f08059e5408d2ec2cbe9915d62e01d to your computer and use it in GitHub Desktop.
Individually zip or 7z each file into a separate archive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SETLOCAL | |
ECHO. | |
SET TYPE= | |
SET FILE=%~2 | |
IF /I "%~1" EQU "zip" SET TYPE=zip | |
IF /I "%~1" EQU "7z" SET TYPE=7z | |
IF "%TYPE%" EQU "" GOTO :USAGE | |
IF "%FILE%" EQU "" GOTO :USAGE | |
:START | |
ECHO Creating a %TYPE% file for each non-%TYPE% file matching "%FILE%". | |
PAUSE | |
ECHO. | |
FOR %%I IN ("%FILE%") DO ( | |
echo File: %%I | |
IF /I "%%~xI" NEQ ".%TYPE%" ( | |
IF NOT EXIST "%%~nI.%TYPE%" ( | |
REM ECHO Creating: %%~nI.%TYPE% . . . | |
IF "%TYPE%" EQU "zip" zip.exe -9 "%%~nI.zip" "%%I" | |
IF "%TYPE%" EQU "7z" 7z.exe a -mx9 "%%~nI.7z" "%%I" | |
) ELSE ( | |
ECHO Warning: "%%~nI.%TYPE%" already exists. Skipping. | |
) | |
) | |
) | |
GOTO :EOF | |
:USAGE | |
ECHO USAGE: [zip^|7z] filename_or_wildcard | |
ECHO EXAMPLE: %~0 zip *.a26 | |
GOTO :EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment