Extract folder content from 7z archive to specific folder

The name of the pictureThe name of the pictureThe name of the pictureClash 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












share|improve this question























  • 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














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












share|improve this question























  • 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












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












share|improve this question















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









linux command-line 7-zip






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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










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






share|improve this answer




















  • 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











  • That's what I feared, I really hoped it could be done in a single command
    – Matteo Tassinari
    48 mins ago










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "3"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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






share|improve this answer




















  • 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











  • That's what I feared, I really hoped it could be done in a single command
    – Matteo Tassinari
    48 mins ago














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






share|improve this answer




















  • 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











  • That's what I feared, I really hoped it could be done in a single command
    – Matteo Tassinari
    48 mins ago












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






share|improve this answer












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







share|improve this answer












share|improve this answer



share|improve this answer










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 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
















  • 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











  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

Confectionery