Extract Multiple .rar Archives to a Single Folder Using .rar Names

I'd like to extract multiple .rar files to one uncompressed folder, keeping the name of each file (which will be different types) within these compressed archives the same as the archived folders themselves. How can this be done via a right-click menu once the files have been selected? I have WinRar installed, but I believe its right-click menu options cannot do this, just extract the archives' content with their original names to the archive folders extracted.

To clarify, in my Documents folder, I have three .rar archives named 1, 2, & 3, but inside them, their file names are different. I'd like to mass extract them to my Documents folder so each is then called by its individual archive's name instead of its original file name within the compressed folder.

I have checked settings within WinRar and cannot see a way of doing this in Opus, so was hoping you'd be able to offer a solution.

Many thanks.

Not sure if I fully understood what you wanted to do, but here's an idea for a button:

Copy FILE={filepath} EXTRACT=sub TO=/mydocuments

Thanks! I'll give it a try, even though I don't know how to do it yet. Ideally, I'd like a right-click command once I've highlighted the archives for it to be as easy as possible. I appreciate your expertise and input.

Unfortunately, that function only does the same as "Extract all to Separate Folders". I need the files within the extracts to be extracted outside these to just one area (Documents, for example), renamed to their archive titles.

Could you post a demo archive and how you want the files renamed?

So, for example, I have three .rar files named 1,2, & 3.

In 1, it has two files called a and b; in 2, there is just one file called c; and in 3, there are three files called e, f, & g.

I'd like to be able to mass extract these three archives containing these files to Documents, keeping the individual archive names after doing so. So, when all of archive 1's contents are extracted, they are all called 1 (with their different extensions to allow for this); when all of 2's are extracted, the same; and so on. At the end of the process, I should have just renamed files in Documents from the archives and then the original .rar archives are deleted after successfully doing this.

I see... I think I got it. Here's a little skript for you to try out. Uses /mydocuments as destination.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var fsu = DOpus.FSUtil();

    cmd.deselect = false;
    DOpus.ClearOutput();

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        if (!item.InGroup('Archives')) continue;
        var folderEnum = fsu.ReadDir(item);
        while (!folderEnum.complete) {
            var folderItem = folderEnum.Next();
            var cmdLine = ('Copy FILE="' + folderItem + '" AS="' + item.name_stem + folderItem.ext + '" TO=/mydocuments');
            DOpus.Output(cmdLine);
            cmd.RunCommand(cmdLine);
        }
    }
}

35559.dcf (1.5 KB)


2 Likes

Fantastic! Does as wanted, apart from deleting the original .rar files at the end of the successful extractions, but I can manually do that, if necessary. Thank you very much! A brilliant solution!

Well... you have left some room for dessert, haven't you?

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var fsu = DOpus.FSUtil();
    var dlg = clickData.func.Dlg();

    cmd.deselect = false;
    DOpus.ClearOutput();

    var deleteFiles = DOpus.Create.Vector();
    var deleteMessage = 'Files to be deleted:\n';

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        if (!item.InGroup('Archives')) continue;

        deleteFiles.push_back(item);
        deleteMessage += '\n' + item.name;

        var folderEnum = fsu.ReadDir(item);
        while (!folderEnum.complete) {
            var folderItem = folderEnum.Next();
            var cmdLine = ('Copy FILE="' + folderItem + '" AS="' + item.name_stem + folderItem.ext + '" TO=/mydocuments');
            DOpus.Output(cmdLine);
            cmd.RunCommand(cmdLine);
        }
    }

    cmd.SetFiles(deleteFiles);
    if (cmd.filecount > 0 && dlg.Request(deleteMessage) == 1) cmd.RunCommand('Delete QUIET');
}

35559.dcf (2.3 KB)

4 Likes

Perfect! Thanks again!