Is there a way to extract .rar files to a folder named after the .rar file?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Jorge24
Junior Member
Junior Member
Posts: 53
Joined: 2016-11-06, 18:14 UTC
Location: USA

Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Jorge24 »

I use WinRAR to extract .rar files and was wondering if there's a way to replicate the same WinRAR workflows within Total Commander.

Workflow 1:
Right-click rar file and select "extract to folder" (or use a keyboard shortcut).
Total Commander creates a folder with the same name as the rar file's name.

Workflow 2:
Extract the contents of the rar file to the folder it's located at without creating a new folder.
User avatar
petermad
Power Member
Power Member
Posts: 15999
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *petermad »

Here are two external commands for that:

Code: Select all

[em_extract-to_folder_with_archivename]
cmd=cm_UnpackFiles
param=/GT="%O\"
button=wcmicons.dll,31
menu=Extract archive under cursor to folder in curent folder with same name as archive

[em_extract-to_current_folder]
cmd=cm_UnpackFiles
param=/GT="."
button=wcmicons.dll,31
menu=Extract archive under cursor to current folder
You can use the em_command in a Button in the button bars, as a Keyboard shortcut, in the Main menu and the Start menu and the Directory hotlist - But you can NOT use it in the context menu (Right-click).

The commands work for all supported archive formats, not just .rar.


Run:

Code: Select all

hh.exe %COMMANDER_PATH%\TOTALCMD.CHM::dlg_choosecommand.htm
for Help about the cm_UnpackFiles command parameters
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Dalai
Power Member
Power Member
Posts: 9945
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Dalai »

There's also a manual way via the Alt+F9 (Unpack files) dialog. Prerequisite is that both TC panels are showing the same directory, i.e. the one where the archive resides.

If the option "Unpack each archive to a separate subdir (name of the archive)" is checked, your workflow 1 would be covered. Unchecking the option this option would cover your second workflow.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
petermad
Power Member
Power Member
Posts: 15999
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *petermad »

Prerequisite is that both TC panels are showing the same directory
You can also just delete the proposed directory, then the directory in the active panel will be used.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Dalai
Power Member
Power Member
Posts: 9945
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Dalai »

2petermad
Ah yes, thanks. I always forget about that.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Jorge24
Junior Member
Junior Member
Posts: 53
Joined: 2016-11-06, 18:14 UTC
Location: USA

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Jorge24 »

Cool! Thanks both! There's only one thing I'm missing now compared to WinRAR. Is there a way to do "Browse with Total Commander" by default when I double left-click a .rar archive?

I tried doing the "right-click > Open with > Total Commander > Always" method but that ends up launching a new instance of Totalcmd instead of opening it in the current panel like when you do "right-click > Browse with Total Commander"
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6951
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Horst.Epp »

Jorge24 wrote: 2025-03-24, 17:25 UTC Cool! Thanks both! There's only one thing I'm missing now compared to WinRAR. Is there a way to do "Browse with Total Commander" by default when I double left-click a .rar archive?

I tried doing the "right-click > Open with > Total Commander > Always" method but that ends up launching a new instance of Totalcmd instead of opening it in the current panel like when you do "right-click > Browse with Total Commander"
Configuration / Packer / Treat archives like directories
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
Jorge24
Junior Member
Junior Member
Posts: 53
Joined: 2016-11-06, 18:14 UTC
Location: USA

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Jorge24 »

Now it's perfect, thanks! Is there way to also to create a ZIP file and place it on the same folder where the files are at?
I tried the method of deleting the proposed directory that works with extracting but it said "You cannot copy a file to itself!"

Is there a setting/ini file where I can set the proposed directory? or that's hard coded?
User avatar
Dalai
Power Member
Power Member
Posts: 9945
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Dalai »

Jorge24 wrote: 2025-03-24, 19:35 UTCIs there way to also to create a ZIP file and place it on the same folder where the files are at?
Associate Ctrl+Alt+F5 with the cm_PackFiles command in Options > Misc > Redefine hotkeys. After doing that you can press Ctrl+Alt+F5 to create an archive in the same directory level. It's the same command that's associated with Alt+F5, but pressing the additional Ctrl key changes the behavior of that function (leaving out the path).
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Jorge24
Junior Member
Junior Member
Posts: 53
Joined: 2016-11-06, 18:14 UTC
Location: USA

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Jorge24 »

ohh neat! Is there a way to pass an argument or something to cm_PackFiles so that I can leave out the path by pressing just Alt+F5?
I read there's a T="path" argument but when I leave it blank like T="" it still adds the other panel's path
User avatar
petermad
Power Member
Power Member
Posts: 15999
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *petermad »

2Jorge24

You need a / before the T - like this: https://tcmd.madsenworld.dk/packfilestocurrentdir.png

this will create the archive file in the source folder.

Remember to click the button with the green check-mark to save the change.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Jorge24
Junior Member
Junior Member
Posts: 53
Joined: 2016-11-06, 18:14 UTC
Location: USA

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Jorge24 »

ohh I see, thanks! It's all working perfect now! Do you add a slash because each argument needs a slash before it? or does the slash in this case just represent the current directory?
User avatar
Dalai
Power Member
Power Member
Posts: 9945
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *Dalai »

Yes, a slash is needed before the T. It's used to mark the start of a command switch, cm_PackFiles being the command and /T being the switch (or parameter). It's the same thing as for many Windows command line commands.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
petermad
Power Member
Power Member
Posts: 15999
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *petermad »

Do you add a slash because each argument needs a slash before it?
You only need one slash even if you use more parameters - like: /DRBT="."

Help wrote:cm_PackFiles
All the options shown in the dialog box can be passed as parameters (starting with a slash). Each of the checkbox options takes an optional parameter 1 or 0.
T="target name": path and file name of the archive. Use T="" or T="." to pack to source directory with default name, or T="c:\path\." to pack to given path with default name.
D: Also pack path names (only recursed)
R: Recursively pack subdirectories
S: Multiple disk archive (ZIP, 7-ZIP, ARJ, RAR, ACE)
M: Move to archive
X: Create self extracting archive
O0..4,7,8: Overwrite options, numbers as in the F5 copy dialog box. 5,6 and 9 are not supported.
A: Create separate archives, one per selected file/dir
B: Leave out base directory when packing folders
C: Encryption method: 0=old ZIP enryption, 1=AES128, 2=AES192, 3=AES256, -1=default method last chosen by the user
P="password": provide password (needs /C option)
G: Go: Start copying immediately
E="extension": packer type as shown in the pack dialog
F="options": Additional 7-Zip options like setting the pack method or header compression, e.g. /F="-m0=PPMD -mhc=on"
Z0..10: ZIP compression rate, 0=stored, 10=LZMA. Only used for ZIP, GZ and TGZ (the latter two 1..9 only)

cm_UnpackFiles
All the options shown in the dialog box can be passed as parameters (starting with a slash). Each of the checkbox options takes an optional parameter 1 or 0.
T="path": Destination path, MUST be in double quotes. use T="." to unpack to the location of the archive
D: Unpack the path names of the files
O0..4,7,8: Overwrite options, numbers as in F5 copy dialog. 5, 6 and 9 are not supported.
S: Extract each archive into a separate subdirectory
P="Password": Enter password (only ZIP, RAR and internal 7-Zip)
A="Password": specify password for archive (encrypted filenames, only 7-Zip internal)
G: Go: Start unpacking immediately
W="wildcard": Extract only files of this type. Double quotes " must be specified twice, e.g. for names with spaces: /W="file1.txt ""file 2.txt"" file3.txt". Special case: /W="" unpacks selected files from an open archive (like F5).
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
white
Power Member
Power Member
Posts: 5747
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Is there a way to extract .rar files to a folder named after the .rar file?

Post by *white »

Dalai wrote: 2025-03-25, 09:18 UTC Yes, a slash is needed before the T. It's used to mark the start of a command switch, cm_PackFiles being the command and /T being the switch (or parameter). It's the same thing as for many Windows command line commands.
It's not the same thing as for many Windows command line commands. The slash is used to mark the start of the command switches (plural).
petermad wrote: 2025-03-25, 10:38 UTC
Do you add a slash because each argument needs a slash before it?
You only need one slash even if you use more parameters - like: /DRBT="."
In fact, using only one slash is the syntax. Adding more slashes doesn't do anything. These commands do the same:
cm_packfiles /D0R0
cm_packfiles /D0 R0
cm_packfiles /D0 /R0
Post Reply