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.


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.

There any free, lightweight app to merge PDF files as one?

As the name of the title in this post says it all. Okay, maybe not all it says because I want it on Linux desktop.

Looking for a tool that can combine different PDF into one big PDF file. I don’t need to modify the content of the PDFs. All important is merging them together as a group.

Sorting it probably comes as second important feature. But I can get on without that as long as it stays in sequence however I added each PDF file.

Lastly simple. No over the top effects. Prefer GUI app. Open to command line.


For that purpose, I have personally used PDF-Shuffler, It is a GUI desktop application on Linux. I used it back then on Ubuntu, but it should be available in all other major distros. Google for it. I know it is included in the official package management repositories of Ubuntu.

PDF-Shuffler can collate, sort (through drag and drop) and rotate the PDF files individually. As an added bonus, it can crop PDFs too.

It is a straightforward app. Stable for all those times I’ve used. But my usage is fairly moderate only.

I also suggest using pdftk for command line if you fancy that kind of stuff. You can combine PDFs into one as simple as:

:~$ pdftk file-1.pdf file-2.df file-3.pdf output my-merged.pdf

This tool can do other stuff. You can read its manual for more information. Google about pdftk too for more examples.

Copy and paste a folder

I am trying to make a copy of an OpenFoam tutorial folder to my desktop through Ubuntu since I don’t want to mess up the original files. I use the command line:
cp -r $FOAM_TUTORIAL /mnt/c/Users/username/Desktop

but this error pops up
cp: missing destination file operand after ‘/c/Users/username/Desktop’

Can I get any help with this?

Go to Source
Author: user421564