public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Dale <rdalek1967@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Dolphin and extracting archives, .zip at the moment.
Date: Fri, 17 Jan 2025 01:01:42 -0600	[thread overview]
Message-ID: <b5e8af22-a2e7-5ca2-0282-83cd261d9857@gmail.com> (raw)
In-Reply-To: <Z4aGvNB22m0pXcb3@q>

Frank Steinmetzger wrote:
> 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
>


Well, that went right over my head.  Been reading that on occasion the
past day or so and still not sure, despite your notes, how that works. 
I'm glad the GUI one works.  :-D 

Dale

:-)  :-) 


      reply	other threads:[~2025-01-17  7:01 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
2025-01-17  7:01               ` Dale [this message]

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=b5e8af22-a2e7-5ca2-0282-83cd261d9857@gmail.com \
    --to=rdalek1967@gmail.com \
    --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