Extract folder content from 7z archive to specific folder
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have a 7z archive file which, at the "root" level, contains a couple of files and then a directory, which in turn contains both files and folders, like this:
- file1.txt
- file2.txt
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I would like to know if there is a single command that allows me to extract the content of my_dir
inside a directory of my choice so that the end result is:
- target_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I have tried these commands:
7za x -y archive.7z -o/path/to/target_dir my_dir
7za x -y archive.7z -o/path/to/target_dir 'my_dir/*'
but both created this directory structure:
- target_dir
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
- my_dir
linux command-line 7-zip
add a comment |Â
up vote
2
down vote
favorite
I have a 7z archive file which, at the "root" level, contains a couple of files and then a directory, which in turn contains both files and folders, like this:
- file1.txt
- file2.txt
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I would like to know if there is a single command that allows me to extract the content of my_dir
inside a directory of my choice so that the end result is:
- target_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I have tried these commands:
7za x -y archive.7z -o/path/to/target_dir my_dir
7za x -y archive.7z -o/path/to/target_dir 'my_dir/*'
but both created this directory structure:
- target_dir
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
- my_dir
linux command-line 7-zip
Does this work :7z x archive.7z my_dir -y -r -otarget_dir
?
– harrymc
7 mins ago
Sadly no, same result as the commands I tried.
– Matteo Tassinari
5 mins ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a 7z archive file which, at the "root" level, contains a couple of files and then a directory, which in turn contains both files and folders, like this:
- file1.txt
- file2.txt
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I would like to know if there is a single command that allows me to extract the content of my_dir
inside a directory of my choice so that the end result is:
- target_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I have tried these commands:
7za x -y archive.7z -o/path/to/target_dir my_dir
7za x -y archive.7z -o/path/to/target_dir 'my_dir/*'
but both created this directory structure:
- target_dir
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
- my_dir
linux command-line 7-zip
I have a 7z archive file which, at the "root" level, contains a couple of files and then a directory, which in turn contains both files and folders, like this:
- file1.txt
- file2.txt
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I would like to know if there is a single command that allows me to extract the content of my_dir
inside a directory of my choice so that the end result is:
- target_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
I have tried these commands:
7za x -y archive.7z -o/path/to/target_dir my_dir
7za x -y archive.7z -o/path/to/target_dir 'my_dir/*'
but both created this directory structure:
- target_dir
- my_dir
- file3.txt
- file4.txt
- another_dir
- file5.txt
- file6.txt
- my_dir
linux command-line 7-zip
linux command-line 7-zip
edited 1 hour ago
asked 1 hour ago


Matteo Tassinari
1309
1309
Does this work :7z x archive.7z my_dir -y -r -otarget_dir
?
– harrymc
7 mins ago
Sadly no, same result as the commands I tried.
– Matteo Tassinari
5 mins ago
add a comment |Â
Does this work :7z x archive.7z my_dir -y -r -otarget_dir
?
– harrymc
7 mins ago
Sadly no, same result as the commands I tried.
– Matteo Tassinari
5 mins ago
Does this work :
7z x archive.7z my_dir -y -r -otarget_dir
?– harrymc
7 mins ago
Does this work :
7z x archive.7z my_dir -y -r -otarget_dir
?– harrymc
7 mins ago
Sadly no, same result as the commands I tried.
– Matteo Tassinari
5 mins ago
Sadly no, same result as the commands I tried.
– Matteo Tassinari
5 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
Is there a single command that allows extracting my_dir to a specified directory?
Yes. Use the e
option instead of x
:
7za e -y archive.7z -o/path/to/target_dir my_dir
(x
is Extract with full paths)
e (Extract) command
Extracts files from an archive to the current directory or to the
output directory. The output directory can be specified by -o (Set
Output Directory) switch.
This command copies all extracted files to one directory. If you want
extract files with full paths, you must use x (Extract with full
paths) command.
Source e (Extract) command
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
@MatteoTassinari Then you will have to use the originalx
option and then usemove
to move the contents ofmy_dir
up a level.
– DavidPostill♦
57 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Is there a single command that allows extracting my_dir to a specified directory?
Yes. Use the e
option instead of x
:
7za e -y archive.7z -o/path/to/target_dir my_dir
(x
is Extract with full paths)
e (Extract) command
Extracts files from an archive to the current directory or to the
output directory. The output directory can be specified by -o (Set
Output Directory) switch.
This command copies all extracted files to one directory. If you want
extract files with full paths, you must use x (Extract with full
paths) command.
Source e (Extract) command
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
@MatteoTassinari Then you will have to use the originalx
option and then usemove
to move the contents ofmy_dir
up a level.
– DavidPostill♦
57 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
add a comment |Â
up vote
2
down vote
Is there a single command that allows extracting my_dir to a specified directory?
Yes. Use the e
option instead of x
:
7za e -y archive.7z -o/path/to/target_dir my_dir
(x
is Extract with full paths)
e (Extract) command
Extracts files from an archive to the current directory or to the
output directory. The output directory can be specified by -o (Set
Output Directory) switch.
This command copies all extracted files to one directory. If you want
extract files with full paths, you must use x (Extract with full
paths) command.
Source e (Extract) command
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
@MatteoTassinari Then you will have to use the originalx
option and then usemove
to move the contents ofmy_dir
up a level.
– DavidPostill♦
57 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Is there a single command that allows extracting my_dir to a specified directory?
Yes. Use the e
option instead of x
:
7za e -y archive.7z -o/path/to/target_dir my_dir
(x
is Extract with full paths)
e (Extract) command
Extracts files from an archive to the current directory or to the
output directory. The output directory can be specified by -o (Set
Output Directory) switch.
This command copies all extracted files to one directory. If you want
extract files with full paths, you must use x (Extract with full
paths) command.
Source e (Extract) command
Is there a single command that allows extracting my_dir to a specified directory?
Yes. Use the e
option instead of x
:
7za e -y archive.7z -o/path/to/target_dir my_dir
(x
is Extract with full paths)
e (Extract) command
Extracts files from an archive to the current directory or to the
output directory. The output directory can be specified by -o (Set
Output Directory) switch.
This command copies all extracted files to one directory. If you want
extract files with full paths, you must use x (Extract with full
paths) command.
Source e (Extract) command
answered 1 hour ago


DavidPostill♦
100k25211248
100k25211248
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
@MatteoTassinari Then you will have to use the originalx
option and then usemove
to move the contents ofmy_dir
up a level.
– DavidPostill♦
57 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
add a comment |Â
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
@MatteoTassinari Then you will have to use the originalx
option and then usemove
to move the contents ofmy_dir
up a level.
– DavidPostill♦
57 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
Hi David, thanks for your help, but I fear I may have over-simplified my question, in fact the folder in the archive contains subfolders which I'd like to preserve, see the edit.
– Matteo Tassinari
1 hour ago
@MatteoTassinari Then you will have to use the original
x
option and then use move
to move the contents of my_dir
up a level.– DavidPostill♦
57 mins ago
@MatteoTassinari Then you will have to use the original
x
option and then use move
to move the contents of my_dir
up a level.– DavidPostill♦
57 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
That's what I feared, I really hoped it could be done in a single command
– Matteo Tassinari
48 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1366616%2fextract-folder-content-from-7z-archive-to-specific-folder%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Does this work :
7z x archive.7z my_dir -y -r -otarget_dir
?– harrymc
7 mins ago
Sadly no, same result as the commands I tried.
– Matteo Tassinari
5 mins ago