Ubzip many files
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
-
- Level 2
- Posts: 81
- Joined: Thu Jul 13, 2017 10:03 am
Ubzip many files
Is there a way to unzip many files or does one need to go one by one? I've downloaded a ton of stuff and it is all zipped. It's time consuming.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Ubzip many files
Yes there is. Select several files then select "Extract here". Else, unzip from the command line in a for loop.
-
- Level 2
- Posts: 81
- Joined: Thu Jul 13, 2017 10:03 am
Re: Ubzip many files
Is there a way to extract them each into their own folder so the files do not get mixed up together?
Re: Ubzip many files
Depends on how the creator of the archive did things.
- If the archives are a zipped directory,
unzip *zip
will unzip everything into their own directories - If the archives are just jumbled files, you'll have to do more work. Something like the below.
Code: Select all
#!/bin/bash
#unzip.sh -- quick and dirty script to unzip archives into their own directories.
#Spaces in filenames / starting directory may cause fun(tm). Best to avoid them.
# Usage: die message ...
die() {
printf '%s\n' "$*" >&2
exit 1
}
read -p "Please enter starting directory: " stdir
if [[ ! -d $stdir ]] ; then
printf "${stdir} is not a valid directory."
exit 1
fi
cd $stdir || die
for f in *zip; do
g="${f%.zip}"
mkdir ./"$g"
cd ./"$g" || die
unzip ../"$f"
cd .. || die
done
printf "processing complete."
-
- Level 2
- Posts: 81
- Joined: Thu Jul 13, 2017 10:03 am
Re: Ubzip many files
I'm very inexperienced with the terminal. I know how to change directory. Do I just copy and paste this?
- absque fenestris
- Level 12
- Posts: 4110
- Joined: Sat Nov 12, 2016 8:42 pm
- Location: Confoederatio Helvetica
Re: Ubzip many files
Hi SpacecadetSpacecadet wrote: ⤴Fri Sep 24, 2021 2:40 am I'm very inexperienced with the terminal. I know how to change directory. Do I just copy and paste this?
do you have the possibility to use a Mint or otherwise a Linux in the VirtualBox?
A virtual Linux experimental system can really do a lot to reduce inhibitions and fears of the terminal. If something goes completely wrong, just delete the virtual system. Your data and your settings on your main installation are not at risk at any time.
-
- Level 2
- Posts: 81
- Joined: Thu Jul 13, 2017 10:03 am
Re: Ubzip many files
Yes, I put Virtual Box on this computer but I don't know how to use it. If I can get it set up you recommend playing around with the terminal in it? Before I let myself loose on the real one?
- absque fenestris
- Level 12
- Posts: 4110
- Joined: Sat Nov 12, 2016 8:42 pm
- Location: Confoederatio Helvetica
Re: Ubzip many files
In principle, virtual systems are ideal playgrounds for such exercises. You can really try out all terminal commands, but also scripts like the one above at your leisure. Even several times, until it works and you feel confident.
The prerequisite, however, is 8 GB RAM. Whether it works e.g. with 4 GB RAM is questionable, 10 years ago this was no problem, meanwhile the memory requirement has increased strongly.
The prerequisite, however, is 8 GB RAM. Whether it works e.g. with 4 GB RAM is questionable, 10 years ago this was no problem, meanwhile the memory requirement has increased strongly.
Re: Ubzip many files
yeah, that'd get copy/pasted into a file (e.g. "unzip.sh") and then you would run it withSpacecadet wrote: ⤴Fri Sep 24, 2021 2:40 am I'm very inexperienced with the terminal. I know how to change directory. Do I just copy and paste this?
bash unzip.sh
.Here's a few random zipped files I found on my system, and threw into
~/ziptest
.
Code: Select all
$ pwd
/home/djph/ziptest
$ ls -l
total 64
-rw-r--r-- 1 djph djph 48158 Sep 24 08:01 Final Code.zip
-rw-r--r-- 1 djph djph 296 Sep 24 08:01 openvolt.zip
-rw-r--r-- 1 djph djph 5584 Sep 24 08:01 rc.zip
-rw-r--r-- 1 djph djph 832 Sep 24 08:01 test.zip
/home/djph/Programming/src
, just to show it'll work anywhere) NOTE - you have to use the full/correct path. It doesn't deal with bash expansions like $HOME
or ~
Code: Select all
$ pwd
/home/djph/Programming/src
$ bash unzip.sh
Please enter starting directory: /home/djph/ziptest/
Archive: ../Final Code.zip
inflating: CODE FINAL.txt
Archive: ../openvolt.zip
inflating: openvolt
Archive: ../rc.zip
inflating: rc.lua
Archive: ../test.zip
inflating: testfile.txt
inflating: test.txt
inflating: test.sh
processing complete.
~/ziptest
. As you can see, a new subdirectory is created for each zip archive, and the contents are extracted into the given subdirectory (as opposed to all of them unzipping and jumbling up the files in the parent 'ziptest' directory). Code: Select all
$ pwd
/home/djph/ziptest
$ ls -l
total 80
drwxr-xr-x 2 djph djph 4096 Sep 24 08:06 Final Code
-rw-r--r-- 1 djph djph 48158 Sep 24 08:01 Final Code.zip
drwxr-xr-x 2 djph djph 4096 Sep 24 08:06 openvolt
-rw-r--r-- 1 djph djph 296 Sep 24 08:01 openvolt.zip
drwxr-xr-x 2 djph djph 4096 Sep 24 08:06 rc
-rw-r--r-- 1 djph djph 5584 Sep 24 08:01 rc.zip
drwxr-xr-x 2 djph djph 4096 Sep 24 08:06 test
-rw-r--r-- 1 djph djph 832 Sep 24 08:01 test.zip
$ cd Final\ Code
$ ls -l
total 196
-rw-r--r-- 1 djph djph 199556 Jun 4 19:57 CODE FINAL.txt