Compress all files in a directory separately via command line

How to do this fast and easily? I don’t care about what type of compression was used.

When I say compress I am referring to using a tool such as ZIP to make a file smaller. Separately – that is each file will have its own zipped file, instead of all being bundled into one big one.

ANSWER

On a Linux shell, such as Bash, I can do this command to zip up all the files in a directory individually.

find . -type f -exec zip -D '{}.zip' '{}' \;

The find command allows for finding many things. Here we specify where to look for it through that dot right after the command. Dot means the current directory location. Then the -type f tells it to find only those considered as regular files. Followed by the -exec zip so that when it finds those files it will do a zip on each one. The curly brackets is so that filenames are retained, then appended with a .zip file extension at the end.

Find is recursive. So it will also go down to subdirectories and zip any files in there, and so on. It can be prevented. One way is to use -maxdepth option. If I want it to not recurse deeper I tell it to have a max depth of 1.

find . -maxdepth 1 -type f -exec zip -D '{}.zip' '{}' \;

There are other ways – such as using a for loop on bash – but I’ve always been more comfortable with doing this through the find command.

Then there is also the gzip compression tool. This is another one similar to zip. Gzip command is much simpler and shorter.

gzip *

The * is a wildcard that matches any of the files that are in that current directory. It will ignore directories, so any files in subdirectories will not get compressed. Note that this short command deletes the original file once it’s been compressed. If I want to keep these files, I would put the -k option (long form is --keep).

gzip -k *

These commands will work on perhaps majority of Linux distros, assuming the zip and gzip applications are installed. It will also work on Bash-like shells for Windows. Better yet, Windows 10 has the Windows Subsystem for Linux feature.

How to configure Krusader’s extract context menu to use something other than ark?

I’ve found this context menu in krusader to be very unreliable over the years, it has hardly ever worked for me. Surely it’s possible to configure the context menu to use a custom command, like simply using the zip , ot tar CLI command. I don’t find this in the application settings.

The VFS plugins work great, how come this context menu has to use ARK?

Go to Source
Author: barrymac

ANSWER

Being KDE, it is a very highly configurable desktop environment to the point that it can become overwhelming. It gives you practically a myriad options for customizations for just about everything. I know because I had been a KDE fan/user for several years.

But I think the issue here is on file associations. Krusader, being a KDE application should follow system-wide settings. I don’t see any reason why it should not. As such, it is in my opinion that the file manager by default will use whatever is associated to handle or open a certain file. I’d look for KDE’s file association settings in the Control Panel or some such. Then assign a different application for that file to your liking. That should do the trick.

As for more customizations like using your own script perhaps? It could be possible still under file associations to assign a different application. Don’t have a KDE desktop installed right now so I can’t check this out. Certainly can’t remember too, nor have gone to the extent of doing something like this to handle archives.