RAR/ZIP Extract and Delete in Right Click Menu

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

Posted 2014-11-06T14:26:48.250

Reputation: 436

possible duplicate of How can I add a program to the context menu of all files?

– Ƭᴇcʜιᴇ007 – 2014-11-06T14:43:03.357

@Ƭᴇcʜιᴇ007 I have checked it. But there is not a way to do something like extract and then delete zip file as far as i know. So above link doesnt really answer my question. – Haplo – 2014-11-06T14:46:43.033

This is not currently a feature of WinRAR. – Ramhound – 2014-11-06T14:46:55.027

Make the batch file you suggest, then add it to the context menu as per the linked question. Where are you getting stuck exactly? – Ƭᴇcʜιᴇ007 – 2014-11-06T15:44:39.860

@Ƭᴇcʜιᴇ007 I don't know if this is doable with a batch file. Nor how to do this with it. So.. – Haplo – 2014-11-06T15:51:38.583

Yes unRARing and deleting a file are doable with a batch file, but unfortunately we're not a script/batch writing service. Go do some research and come back with specific questions about specific problems you're running into while implementing it. Hint: Unrar.exe x %1 c:\targetfolder del /q %1. http://www.rarlab.com/rar_add.htm

– Ƭᴇcʜιᴇ007 – 2014-11-06T15:57:48.850

@Ƭᴇcʜιᴇ007 This would only work for .rar files i suppose. Does it unrar/unzip every file type that WinRAR supports? – Haplo – 2014-11-06T16:13:14.870

You don't have to use THAT unrar.exe, find a decompression program that does all the file types you'd like. You could also check the extension in the batch/script file and choose which archive program to use based on that. – Ƭᴇcʜιᴇ007 – 2014-11-06T16:14:42.020

Answers

0

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

FarisHijazi

Posted 2014-11-06T14:26:48.250

Reputation: 1