Config Ark to always extract to subdirectory?

I’ve been using the “Extract here” option from the Dolphin context menu on multiple archives lately, but I’m having issues. Without going into detail, the problem stems from trying to extract multiple archives with identical names. I need to be able to extract multiple archives at once without filenames getting changed.

I would like to configure Ark so that the files extracted from an archive will always be placed in a subdirectory. I found a setting that seems relevant to this, but it seems to only affect archives containing multiple files. I need archives to always extract into a new directory even when it’s just a single file. Can anyone tell me how to achieve this, or if it will be possible?

Thanks for the info.

You could write a shell script and add it to the Dolphin context menu, but how would the script determine what the subdirectory is named if all the archives have the same filename? You would need a unique name that presumably told you which archive it came from, or you could randomly generate subdirectory names but they won’t indicate which archive they came from.

If I were going to the trouble, I’d look at a solution for the whole scenario rather than a solution for part of it. Having identical filenames for archives with different content is fraught with problems for starters.

For single-file archives, Ark won’t need a subfolder; that’s simply the way it’s designed. There isn’t a secret configuration to alter it.

The simplest remedy for getting consistent results in Dolphin is to replace the ark extract operation with a little script that creates a folder from the archive name (perhaps adding a date or anything special) and extracts into it. If not, Ark will continue to dump individual files directly, causing you to experience the same overwrite problems.

The archives don’t have the same filename. The files within different archives often have the same name. I’m working with digital comic .cbz files (zip archives), which typically contain image files using simple filenames consisting of just the page number. 001.jpg, 002.jpg, 003.jpg, etc. So what happens when I try to unzip multiple of these comic archives into the same directory is the filenames collide.

So the archive files each have unique names. The image files in those archives are often using common filenames. I need to be able to extract multiple archives in one go without filename collision. That’s why I need the individual sub-directories to always be used.

I managed to follow the instructions to get a service menu to populate Dolphin’s context menu. I haven’t managed to vibe code my way into a working script though. Once I get that part figured out, will I be able to place the service menu item under the existing context menu for Ark? Or is that level of service menu customization not an option?

Excellent, but since you just need to name the folder the same as the file the following should work in your .desktop file in the service menu (i.e. you don’t need a script)

The --autodestination flag tells Ark to create a folder based on the archive filename.

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/x-7z-compressed;application/x-rar;application/zip;application/x-tar;application/x-bzip2;application/x-gzip;application/x-xz;application/x-lzma;application/x-lha;application/x-rpm;application/x-deb;
Actions=extractToSubfolder;
X-KDE-Priority=TopLevel

[Desktop Action extractToSubfolder]
Name=Extract to Subfolder (Ark)
Icon=ark
Exec=ark --batch --autodestination %F

Thank you for offering the script. I tested it, but it didn’t change the extract behaviour as I needed. I was able to get help from a chatbot to sort out that I do need a script to force the creation of a sub-directory in all use cases. I got a script that works, and added it to the exec line in the service menu. Now it all works.

However, I’d like to be able to organize the service menu item listing in Dolphin’s context menu if possible. Can I move the newly created service menu into the Ark “Extract” sub-menu somehow?

Yes, but you shouldn’t.

You’d need to edit/add entries in the default service menu location instead of your profile location. Which will likely get overwritten on updates and/or cause other issues.

Gotcha. Disappointing to hear, but thanks for sharing.