Re: Script to conditionally find and compress files recursively

Liste des GroupesRevenir à col misc 
Sujet : Re: Script to conditionally find and compress files recursively
De : joebeanfish (at) *nospam* nospam.duh (Joe Beanfish)
Groupes : comp.os.linux.misc
Date : 11. Jun 2024, 15:58:23
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v49omf$12c3q$1@dont-email.me>
References : 1
User-Agent : Pan/0.146 (Hic habitat felicitas; 8107378 git@gitlab.gnome.org:GNOME/pan.git)
On Tue, 11 Jun 2024 14:53:27 +0800, J Newman wrote:

Hi, I'm interested in writing a script that will:
 
1. Find and compress files recursively
2. After the first 5 seconds of compressing, if the compression ratio >1
(i.e. the compressed file will be larger than the uncompressed file), it
tries another compression algorithm.
3. If the other compression algorithm still has a ratio >1, it tries
another algorithm, until a list is exhausted.
4. If the list is exhausted, it skips compressing that file.
 
Any suggestions on how to proceed?

You could use dd to extract a representative chunk of the file to
compress and compare size.

uncompressedsize=$(dd status=none if="$file" bs=1M count=1|wc -c)
compressedsize=$(dd status=none if="$file" bs=1M count=1|$compresscmd|wc -c)

You could get fancy and try all the compression commands you have
and pick the one with smallest output for the actual compression.
That's all assuming the beginning of the file is representative of
the content throughout. If it's not, no way to tell without compressing
the whole thing.

Date Sujet#  Auteur
11 Jun 24 * Script to conditionally find and compress files recursively16J Newman
11 Jun 24 +- Re: Script to conditionally find and compress files recursively1D
11 Jun 24 +- Re: Script to conditionally find and compress files recursively1Joe Beanfish
12 Jun 24 +* Re: Script to conditionally find and compress files recursively12Grant Taylor
12 Jun 24 i+* Re: Script to conditionally find and compress files recursively6Richard Kettlewell
12 Jun 24 ii`* Re: Script to conditionally find and compress files recursively5D
13 Jun 24 ii `* Re: Script to conditionally find and compress files recursively4J Newman
13 Jun 24 ii  `* Re: Script to conditionally find and compress files recursively3D
14 Jun 24 ii   `* Re: Script to conditionally find and compress files recursively2Grant Taylor
14 Jun 24 ii    `- Re: Script to conditionally find and compress files recursively1D
13 Jun 24 i`* Re: Script to conditionally find and compress files recursively5J Newman
13 Jun 24 i `* Re: Script to conditionally find and compress files recursively4Anssi Saari
13 Jun 24 i  +- Re: Script to conditionally find and compress files recursively1D
14 Jun 24 i  `* Re: Script to conditionally find and compress files recursively2Computer Nerd Kev
14 Jun 24 i   `- Re: Script to conditionally find and compress files recursively1Computer Nerd Kev
15 Jun 24 `- Re: Script to conditionally find and compress files recursively1J Newman

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal