public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Frank Steinmetzger <Warp_7@gmx.de>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Dolphin and extracting archives, .zip at the moment.
Date: Tue, 14 Jan 2025 16:46:15 +0100	[thread overview]
Message-ID: <Z4aGvNB22m0pXcb3@q> (raw)
In-Reply-To: <c259ccf6-23c7-0ddb-b87a-27e46c3be42d@gmail.com>

Am Tue, Jan 14, 2025 at 07:06:16AM -0600 schrieb Dale:
> Michael wrote:
> > On Monday 13 January 2025 14:17:41 Greenwich Mean Time Dale wrote:
> >>
> > It does this by default when you select to 'Extract here'.  For example, the 
> > archive foo.zip will be extracted into a new directory called foo/ and all 
> > compressed files in foo.zip will be extracted into foo/.
> > […]
> 
> That seems to work like the old way.  I guess the default changed but it
> didn't make sense given how it used to work. 

I thought it would behave like you expected – always create a subdir for 
each ZIP. I could reproduce that it does not. So I looked at Ark’s settings: 
there is an option to create a subdirectory for a ZIP as soon as the zip 
contains more than one item. So it is still there, but not for every file.

> >> I tried to figure out how to do this on the command line but my head
> >> hurts.  Banging that wall isn't any fun. 
> > I don't think a single command can achieve this.  Unzip will ask if you want 
> > to overwrite files already extracted in a previous attempt and it will create 
> > a directory to store the extracted files if one does not exist, but it will 
> > not ask to rename an existing directory.
> >
> >
> >> Anyone been able to figure out how to do this?  I got a few hundred .zip
> >> files and doing them one by one just isn't a good option. 
> >>
> >> Dale
> >>
> >> :-)  :-) 
> 
> 
> I figured if there was a command line way, it would require sed, awk,
> find and other things I don't understand.

Don’t give one-liners more credit than they’re due. All you need is a 
for-loop over all ZIP files, calculate an ouput dir by removing the trailing 
“.zip”, and finally call unzip with both:

for z in *.zip; do unzip "$z" -d "${z%.zip}"; done

If you want to be smart, omit the extraction if the output directory already 
exists, to avoid overwriting stuff:

# for-loop:        cut off ".zip"  does dir exist? yes                   no
for z in *.zip; do d="${z%.zip}";  [ -d "$d" ] &&  echo "Skipping $z" || unzip "$z" -d "$d"; done

-- 
Grüße | Greetings | Salut | Qapla’
Please do not share anything from, with or about me on any social network.

...llaw eht no rorrim ,rorriM


  reply	other threads:[~2025-01-14 15:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13  3:03 [gentoo-user] Dolphin and extracting archives, .zip at the moment Dale
2025-01-13  3:56 ` eric
2025-01-13  4:47   ` Dale
2025-01-13  9:10     ` Michael
2025-01-13 14:17       ` Dale
2025-01-13 18:37         ` Michael
2025-01-14 13:06           ` Dale
2025-01-14 15:46             ` Frank Steinmetzger [this message]
2025-01-17  7:01               ` Dale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z4aGvNB22m0pXcb3@q \
    --to=warp_7@gmx.de \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox