Skip to content

Instantly share code, notes, and snippets.

@Lord-Memester
Forked from FarisHijazi/Unzip_and_delete.reg
Last active January 7, 2025 19:39
Show Gist options
  • Save Lord-Memester/e91d34dc3d6880a9e541fdba188732bb to your computer and use it in GitHub Desktop.
Save Lord-Memester/e91d34dc3d6880a9e541fdba188732bb to your computer and use it in GitHub Desktop.
7zip: Unzip and delete context menu. Registry entry and .bat file for windows context menu "unzip and delete" command. instead of needing to unzip, then delete an archive manually
@echo off
set output_dir=%~n1
IF EXIST "%output_dir%\" (
echo "%output_dir%\" already exists, gonna increment the name
set "n=0"
:loop
set /a n+=1
set "output_dir=%output_dir%_%n%"
if exist "%output_dir%" echo "%output_dir%" already exists & goto :loop
)
"%ProgramFiles%\7-Zip\7z.exe" x %1 -o"%output_dir%\"
IF %ERRORLEVEL% EQU 0 IF EXIST "%output_dir%\" (
echo "%output_dir%\" was created
del %1
) else (
Echo An error was found & pause
)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Unzip and delete]
"icon"="C:\\Program Files\\7-Zip\\7zG.exe"
[HKEY_CLASSES_ROOT\*\shell\Unzip and delete\command]
@="\"<PATH TO>\\unzip_and_delete.bat\" \"%1\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment