0

In WinRAR, is there a way to use something like 'Extract And Delete Zip File' in context menu? I just need this option, it can be whether a batch file or another program that has this in context menu ( right click menu ). Is there a way to achieve this?

Edit: I need something like this, nothing more:

Img

Haplo
  • 436

1 Answers1

1

As mentioned in the comments, you can make a registry entry that calls a batch file to unzip then delete.

I've created an example that uses 7zip (which you will need to have installed). This should work for all file types supported by 7zip.

You can find the bat file and the .reg files in this gist here.

.bat file:

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
)

"C:\Program Files\7-Zip\7z.exe" e %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
)

Now mine is a bit overkill, it will increment the file name if the extracted folder already exists, and it will NOT delete if an error occurs or if the zip wasn't extracted.

registry file:

; adds a command to all files to "unzip and delete"
[HKEY_CLASSES_ROOT\*\shell\Unzip and delete\command]
@="\"<PATH TO BAT FILE>\\unzip_and_delete.bat\" \"%1\""

; for the icon
[HKEY_CLASSES_ROOT\*\shell\Unzip and delete]
"icon"="C:\\Program Files\\7-Zip\\7zG.exe"

usage

  • Save the .bat file somewhere on your computer
  • add the above registry entry, either manually or by downloading the .reg file and running it. (Be sure to replace <PATH TO BAT FILE> with the path to your batfile "unzip_and_delete.bat")
  • at the end, it should show up in your context menu like in the screenshot: https://ibb.co/s96CsMT