Unpack multiple rars to Containing Folder each

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
yuyuxuan
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-23, 09:41 UTC

Unpack multiple rars to Containing Folder each

Post by *yuyuxuan »

I have several rars

Code: Select all

Main folder\1\A\a.rar
Main folder\2\c.rar 
Main folder\3\B\B.zip
First, I search "Main folder" and list those Rars.
And then alt+F9
I left "Unpack n file(s) to " empty
But I get error "Access denied a\"

Then how can I solve this problem.
User avatar
nsp
Power Member
Power Member
Posts: 1954
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

==> suggest a new feature

Post by *nsp »

As you have seen on the extraction dialog there is no checkbox for in-place decompression. You can suggest a new feature !

If you do not want to wait you can build a kind of script that detect all path and automate decompression calling set to folder, select founded names bases on clipboard, and call decompression ...

Another solution is to use an external decompress tool with a script or tcbl to process each file one by one...

or build you own packer that unpack in place.....
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

1. Get "7z.exe" and "7z.dll" from the installation folder of 7-Zip and put them in your commander folder under "\Tools\7-Zip" or adjust the path in the batch accordingly.

2. Save the following as "Unpack_inplace.cmd" and put it on a button with parameters

Code: Select all

"%L" "%P" "%T"

Code: Select all

@echo off
setlocal enabledelayedexpansion
rem Button Parameters "%L" "%P" "%T"
set tc_lst=%1
set tc_src=%2
set tc_dst=%3

rem Make sure the path is correct
set sevenZipExe=%COMMANDER_PATH%\Tools\7-Zip\7z.exe

if -%3==- echo First parameter must be filelist path, second and third - source and target path. && pause && goto :EOF
for /F "usebackq delims=" %%I in (%tc_lst%) do (
	"!sevenZipExe!" x "%%I" -o"%%~dpI"
)
endlocal
3. Select your archives from the result list and hit the button
yuyuxuan
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-23, 09:41 UTC

Post by *yuyuxuan »

ZoSTeR wrote:1. Get "7z.exe" and "7z.dll" from the installation folder of 7-Zip and put... button
My set is as follows:

Image: http://i730.photobucket.com/albums/ww309/ytyyutianyun/Ashampoo_Snap_20141114_09h37m14s_001_.jpg

But when I button it to my search list. It is just flashing by.
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

To debug replace "cmd /c" with "cmd /k"
and put an "echo " before "!sevenZipExe...

Code: Select all

echo "!sevenZipExe!" x "%%I" -o"%%~dpI"
I don't know how well unicode file names are handled...
yuyuxuan
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-23, 09:41 UTC

Post by *yuyuxuan »

ZoSTeR wrote:To debug replace "cmd /c" with "cmd /k"
and put an "echo " before "!sevenZipExe...

Code: Select all

echo "!sevenZipExe!" x "%%I" -o"%%~dpI"
I don't know how well unicode file names are handled...
I edit the code:

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd""
Thanks, and in window, it shows:

Code: Select all

'"C:\Program Files\TotalCMD64\Unpack_inplace.cmd"" "C:\Users\yuyuxuan\AppData\Lo
cal\Temp\CMD783.tmp" "" "C:\' is not recognized as an internal or external comma
nd,
operable program or batch file.

C:\Program Files\TotalCMD64>
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

Just use

Code: Select all

cmd /k "C:\Program Files\TotalCMD64\Unpack_inplace.cmd"
. Don't use double quotes.
yuyuxuan
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-23, 09:41 UTC

Post by *yuyuxuan »

ZoSTeR wrote:Just use

Code: Select all

cmd /k "C:\Program Files\TotalCMD64\Unpack_inplace.cmd"
. Don't use double quotes.
If I move the double quotes into one quote. It will get error, like that:

Code: Select all

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

C:\>
Which seems to interrupt by the space of "Program Files"
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

Just use normal quotes.
Neither

Code: Select all

""c:\
nor

Code: Select all

'c:\
but these:

Code: Select all

"c:\
yuyuxuan
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-23, 09:41 UTC

Post by *yuyuxuan »

ZoSTeR wrote:Just use normal quotes.
Neither

Code: Select all

""c:\
nor

Code: Select all

'c:\
but these:

Code: Select all

"c:\
Yes, I use double quotation marks instead of two single quotation marks

And in fact, when I use command

Code: Select all

"%COMMANDER_PATH%\Unpack_inplace.cmd"
Your cmd works, and I really want to know why the code

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd""
will error. :?:


PS:

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd""

This is what

Code: Select all

 help cmd
says about quoting:

Code: Select all

If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters:

If all of the following conditions are met, then quote characters on the command line are preserved:

no /S switch
exactly two quote characters
no special characters between the two quote characters, where special is one of: &<>()@^|
there are one or more whitespace characters between the two quote characters
the string between the two quote characters is the name of an executable file.
Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character.
So double the first and last quotes .

And can you explain about the code

Code: Select all

if -%3==- 
Thank you
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

I checked again and you're right about double quoting when using cmd.exe and not just the cmd file.

The line

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd""
gives you an error because the parameters are added. So its basically

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd"" "%L" "%P" "%T"
which is wrong.

When used with extra quotes they must be at the end

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd" "%L" "%P" "%T""
The line

Code: Select all

if -%3==-
tests if the third parameter is empty so
it's either

Code: Select all

if -==-
or

Code: Select all

if -ContentOfParam==-
The line

Code: Select all

if X%3==X
would do the same.
yuyuxuan
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-23, 09:41 UTC

Post by *yuyuxuan »

ZoSTeR wrote:I checked again and you're right about double quoting when using cmd.exe and not just the cmd file.

The line

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd""
gives you an error because the parameters are added. So its basically

Code: Select all

cmd.exe /K ""C:\Program Files\TotalCMD64\Unpack_inplace.cmd"" "%L" "%P" "%T"
which is wrong.

......[/code]
or

Code: Select all

if -ContentOfParam==-
The line

Code: Select all

if X%3==X
would do the same.
Thank you for solving my problem.
sticazzi
Junior Member
Junior Member
Posts: 39
Joined: 2007-09-09, 14:56 UTC

Post by *sticazzi »

ZoSTeR wrote:so
it's either

Code: Select all

if -==-
or

Code: Select all

if -ContentOfParam==-
:shock: gulp gulp, I've never seen this syntax ("-==-"): could you give me more info (web page, etc.)? I don't find any info about it :cry:

Many thanks
User avatar
nsp
Power Member
Power Member
Posts: 1954
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

sticazzi wrote:
ZoSTeR wrote:so
it's either

Code: Select all

if -==-
or

Code: Select all

if -ContentOfParam==-
:shock: gulp gulp, I've never seen this syntax ("-==-"): could you give me more info (web page, etc.)? I don't find any info about it :cry:

Many thanks
ZoSTeR replaced his % parameter with either "" or "ContentOfParam" as the interpreter would do....
To get some info of script visit Rob van der Woude's Scripting Pages under Batch section ....
For more power you can use powershell...
For more automation you can use PowerPro or AutoIt or AHK ..... (if you decide to invest on AutoIt, you can give a look to TCIMG )
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

You can't compare empty strings or variables in batch so you have to put an additional character in front of it.
Post Reply