Sample Header Ad - 728x90

How can I multithreadedly extract several 7z archives into their own folder, using the archive name as the folder name?

1 vote
2 answers
818 views
To extract all 7z archives into their own folder, using the archive name as the folder name, I run the command:
7z x "*.7z" -o*
E.g., if one has the two files a.7z and b.7z, then folders a and b will be created and they'll contain the content of a.7z and b.7z (keeping the directory structure), respectively. Sometimes, I have many 7z archives, and I'd like to extract them using multiple cores. I read this [answer](https://unix.stackexchange.com/a/690784/16704) by [Artem S. Tashkinov](https://unix.stackexchange.com/users/260833/artem-s-tashkinov) : > 7z decompression is single threaded and that's the limitation of the compression format Therefore, I am looking at using parallel, since in my case I have multiple 7z archives. I tried:
parallel -j4 '7z x {} -o{}' ::: *.7z
However, if we go back to the example with the two files a.7z and b.7z, the command will try to extract the two files a.7z and b.7z to the folders a.7z and b.7z instead of a and b, which will crash the execution since a.7z and b.7z are already taken and are files. How can I fix that? I want to have two folders, a and b. If that matters, I use Ubuntu.
Asked by Franck Dernoncourt (5533 rep)
Dec 23, 2023, 03:33 PM
Last activity: Dec 23, 2023, 06:18 PM