#1 Le 09/11/2015, à 12:22
- Compte anonymisé
[bash] mon script pour optimiser la taille des fichiers
Bonjour,
un script de ma réalisation, qui permet d'optimiser la taille des fichiers avec différentes opérations selon le type avec de nombreux programmes inclus ou non dans la distribution.
Ce que le script fait :
optimise la compression des archives (zip, rar, ...) et choisi une compression supérieur quand nécessaire (zip --> 7zip, ...)
optimise la compression des images (gif, png, jpg, ...)
converti les données non compressées sans perte (wav --> flac, bmp --> png, xcf --> xcf.gz, svg --> svgz, ...)
optimise le code de différents fichiers (css, php, html, ...)
efface les fichiers inutiles (temporaire, vide, ...)
Comment :
exécute uniquement si le ou les programmes existe (passe au fichier suivant si un programme n'existe pas)
conserve date de fichier original
récursivité (décompresse le contenu des archives pour une taille optimale du fichier finale, pas de conversion de format de fichier à l'intérieur d'une archive)
journalisation (~/opti.csv)
et 100% sans perte de données
Fonctionnement :
opti.sh fichier
opti.sh dossier (. pour dossier actuel)
pour l'instant le script utilise que le premier argument et ne fonctionne que avec un argument
!! a utiliser bien sur qu'a vos risque et périls, aucune garantie de fonctionnement, faites des sauvegardes et vérifier vos fichiers !!
#!/bin/bash
verify()
{
type $@ > /dev/null ||(echo "Erreur : un (ou plusieurs) programme(s) $@ non trouvé(s)"&&continue)
}
comparaison()
{
s2=$(ls -l /tmp/"$b"|awk '{print $5}')
echo "Gain "$(expr $s - $s2) soit $(echo "scale=2;(100*$s)"/$s2-100|bc)
}
extract()
{
rm -rf "/tmp/opti/$b/"
unar -nr -t -f -D -q -o "/tmp/opti/$b/" "$a" > /tmp/null
}
recur()
{
r=$(expr $r + 1)
export r
for i in ${!path[*]};do export path_$i="${path[$i]}";done
bash $0 /tmp/opti/"$b"/
r=$(expr $r - 1)
sleep 1
}
compresszip()
{
rm -rf /tmp/"$b"
if [[ $r -lt 1 ]]
then advzip -4 -a /tmp/"$b" /tmp/opti/"$b"/* > /tmp/null
else advzip -0 -a /tmp/"$b" /tmp/opti/"$b"/* > /tmp/null
fi
mv /tmp/"$b" "$a"
}
compressgz()
{
rm -rf /tmp/"$b"
if [[ $r -lt 1 ]]
then advdef -4 -a /tmp/"$b" /tmp/opti/"$b"/* > /tmp/null
s2=$(ls -l /tmp/"$b"|awk '{print $5}')
if [[ $s2 -lt $s ]];then mv /tmp/"$b" "$a";fi
else advdef -0 -a /tmp/"$b" /tmp/opti/"$b"/* > /tmp/null
mv /tmp/"$b" "$a"
fi
}
compress7z()
{
rm -rf /tmp/"$b"
ne="7z"
if [[ $r -lt 1 ]]
then 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on /tmp/"${b%.*}".$ne /tmp/opti/"$b"/* > /tmp/null
s2=$(ls -l /tmp/"${b%.*}".$ne|awk '{print $5}')
if [[ $s2 -lt $s ]];then rm "$a"&&mv /tmp/"${b%.*}".$ne "${a%.*}".$ne;fi
else 7z a -mx=0 /tmp/"$b" /tmp/opti/"$b"/* > /tmp/null
mv /tmp/"$b" "$a"
fi
}
compressrar()
{
rm -rf /tmp/"$b"
rar a -m0 /tmp/"$b" /tmp/opti/"$b"/* > /tmp/null
mv /tmp/"$b" "$a"
}
if [[ $r == "" ]]
then r=0
path[$r]="$1"
rm ~/opti.csv 2>/dev/null
echo "level;filename;old size;new size" > ~/opti.csv
fi
mkdir /tmp/opti 2>/dev/null
find "$1" -type f \( -name '*.swp' -o -name 'wget.log' -o -name 'foobar*' -o -name '*~' -o -name '.netrwhist' -o -name "Thumbs.db" -o -name "desktop.ini" -o -name "AlbumArt*.jpg" -o -name "*.bak" -o -name "*.old" -o -name "*.log" -o -name "*.tmp" -o -name "._.DS_Store" -o -name "System Volume Information" -o -empty \)|while read a
do echo "$r;$a;$s;deleted" >> ~/opti.csv
rm -rf "$a"
done
find "$1" -empty -delete
find "$1" -type f|while read a
do b=$(basename "$a")
export a
export b
s=$(ls -l "$a"|awk '{print $5}')
ne=""
m=$(stat -c "%Y" "$a")
## lancement scan
case "${b##*.}" in
docx|DOCX|xlsx|XLSX|pptx|PPTX|epub|EPUB|odt|ODT|ods|ODS|odp|ODP|odb|ODB|odg|ODG|odf|ODF|jar|JAR)
verify unar advzip
extract
recur
compresszip
;;
7z|7Z)
verify unar 7z
extract
recur
compress7z
;;
zip|ZIP)
verify unar advzip 7z
extract
recur
if [[ $r -lt 1 ]]
then compress7z
else compresszip
fi
;;
rar|RAR)
verify unar advzip 7z
extract
recur
if [[ $r -lt 1 ]]
then compress7z
else compressrar
fi
;;
gz|GZ|tgz|TGZ|xcfgz|XCFGZ|svgz|SVGZ)
verify unar advdef
extract
recur
compressgz
;;
png|PNG|tif|TIF)
verify optipng
optipng "$a" &> /tmp/null
;;
bmp|BMP)
verify optipng
ne=png
optipng "$a" &> /tmp/null &&rm -f "$a"
;;
jpeg|JPEG|jpg|JPG)
verify jpegoptim
jpegoptim "$a" > /tmp/null
;;
xcf|XCF)
verify gzip
if [[ $r -lt 1 ]]
then
ne=xcfgz
gzip -c "$a" > /tmp/opti/"${b%.*}".$ne
advdef -4 -z /tmp/opti/"${b%.*}".$ne > /dev/null
mv /tmp/opti/"${b%.*}".$ne "${a%/*}"/"${b%.*}".$ne&&rm -f "$a"
fi
;;
exe|EXE|dll|DLL|sys|SYS|ocx|OCX|scr|SCR|cpl|CPL)
verify upx
if [[ $r -lt 1 ]]
then upx "$a" 2>&1 /tmp/null
else upx -d "$a" 2>&1 /tmp/null
fi
;;
gif|GIF)
verify gifsicle
gifsicle --optimize=3 "$a" > /tmp/opti/"$b"&&s2=$(ls -l /tmp/opti/"$b"|awk '{print $5}')&&if [[ $s2 -lt $s ]]
then mv /tmp/opti/"$b" "$a"
fi
;;
flac|FLAC)
verify flac
flac --best "$a" -f -o /tmp/opti/"$b" > /tmp/null &&mv -f /tmp/opti/"$b" "$a"
;;
wav|WAV)
verify flac
ne=flac
flac --best "$a" -f -o "${a%.*}".flac > /tmp/null &&rm -f "$a" > /tmp/null
;;
mp3|MP3)
verify mp3packer
mp3packer -f -z "$a"&&mv -f "${a%.*}"-vbr.mp3 "$a" > /tmp/null
;;
##doc|DOC|xls|XLS|chm|CHM)
##docprc.exe -b"$(dirname $a)" "$b" > /tmp/null
##;;
swf|SWF|xml|XML|xsl|XSL|xslt|XSLT|lua|LUA|rdb|RDB)
verify leanify
leanify "$a" > /tmp/null
;;
php|PHP)
sed 's|/\*|\n&|g;s|*/|&\n|g' "$a" | sed '/\/\*/,/*\//d' > "/tmp/opti/$b"&&mv -f "/tmp/opti/$b" "$a"
;;
css|CSS)
verify csstide
csstidy "$a" /tmp/opti/"$b" > /tmp/null &&mv -f /tmp/opti/"$b" "$a"
;;
js|JS)
verify shrinksafe
shrinksafe "$a" > /tmp/opti/"$b"&&s2=$(ls -l /tmp/opti/"$b"|awk '{print $5}')&&if [[ $s2 -lt $s ]]
then mv /tmp/opti/"$b" "$a"
fi
;;
svg|SVG)
verify scour.py
scour.py -i "$a" -o /tmp/opti/"$b" 2> /dev/null
if [[ "$r" -lt 1 ]]
then
ne=svgz
gzip -c /tmp/opti/"$b" > /tmp/opti/"${b%.*}".$ne
advdef -4 -z /tmp/opti/"${b%.*}".$ne > /dev/null
mv /tmp/opti/"${b%.*}".$ne "$(dirname ${a})"/"${b%.*}".$ne&&rm -f "$a"
else
mv /tmp/opti/"$b" "$a"
fi
;;
html|HTML)
verify htmlcompressor.jar
htmlcompressor.jar "$a" > /tmp/opti/"$b" &&mv /tmp/opti/"$b" "$a"
;;
mkv|MKV)
verify mkclean
mkclean --optimize "$a" /tmp/opti/"$b"&&mv /tmp/opti/"$b" "$a"
;;
##pdf|PDF)
##verify pdfsizeopt.py
##pdfsizeopt.py --use-multivalent=no "$a" /tmp/opti/"$b" 2> /dev/null &&mv /tmp/##opti/"$b" "$a"
##rm -f pso*
esac
if [[ $ne != "" ]]
then s2=$(ls -l "${a%.*}".$ne|awk '{print $5}')
touch -t $m "${a%.*}".$ne 2> /dev/null
else s2=$(ls -l "$a"|awk '{print $5}')
touch -t $m "$a" 2> /dev/null
fi
if [[ $s != $s2 ]]
then echo $r $a $s $s2
echo "$r;$a;$s;$s2" >> ~/opti.csv
fi
##echo "$r;${path[$r]};$s;$s2" >> ~/opti.csv
done
moi personnellement je trouve mon script génial et je m'en sert très régulièrement en espérant que ça servent à quelqu'un. (et si quelqu'un connait un équivalent je suis aussi intéressé)
Dernière modification par Compte anonymisé (Le 09/11/2015, à 12:23)
#2 Le 02/01/2016, à 19:33
- scottviger
Re : [bash] mon script pour optimiser la taille des fichiers
Mon dieu, quel travaille de géni!!
Hors ligne
#3 Le 02/01/2016, à 20:31
- Compte anonymisé
Re : [bash] mon script pour optimiser la taille des fichiers
Merci ! merci !
(je sais pas si c'est ironique mais je prend quand même )
#4 Le 15/05/2016, à 10:51
- Compte anonymisé
Re : [bash] mon script pour optimiser la taille des fichiers
Bonjour,
j'ai un peu retravaillé mon script. Pratique avant d'envoyer un fichier sur un cloud ou par mail.
je vais donner des exemples (fichiers pris au hasard sur internet) :
AppBody-Sample-English.docx 732549 --> 63093 (8% de la taille)
UOML Sample.odt 21423 --> 14227 (66% de la taille)
Ch_9.zip 10089176 --> 8587659 (85% de la taille)
lena_gray.bmp 263224 --> 144260 (54% de la taille)
md5sum.exe 49152 --> 25600 (52% de la taille)
Sample-column.xcf 46252 --> 9792 (21% de la taille)
#!/bin/bash
getfilesize()
{
echo $(ls -l "$1"|awk '{print $5}')
}
verify()
{
not=true
if [[ ! $(which "$@") ]]
then
tput setaf 1
echo " $@ not found"
tput setaf 7
return 1
else
return 0
fi
}
extract()
{
if [[ $(which unar) ]]
then
unar -nr -t -f -D -q -o "$tmpdir$b" "$a" > /tmp/null
#no-recursion copy-time force-overwrite no-directory quiet output directory
else
### à améliorer
case "${b##*.}" in
zip|ZIP|docx|DOCX|xlsx|XLSX|pptx|PPTX|epub|EPUB|odt|ODT|ods|ODS|odp|ODP|odb|ODB|odg|ODG|odf|ODF|jar|JAR|cbz|CBZ)
unzip -qq -d "$tmpdir$b" "$a"
;;
rar|RAR|cbr|CBR)
unrar e "$a" -w"$tmpdir$b" > /tmp/null
;;
esac
fi
}
recur()
{
((r++))
path[$r]="${path[$r-1]}"
tput setaf 4
echo "analyse"
tput setaf 7
[[ "$ARCHIVE" == "true" ]]&&uoption="-a"
[[ "$ULTRA" == "true" ]]&&uoption="-u"
([[ "$STRIP" == "true" ]]||[[ "$STRIP_TEMP" == "true" ]])&&soption="-s"
[[ "$FILECHANGE" == "false" ]]&&noption="-n"
[[ "$PNGDECOMPRESS" == "false" ]]&&poption="-nd"
[[ "$LOG" == "false" ]]&&loption="-nl"
BASH_ENV=<(declare -p path) bash $0 $aoption $uoption $soption $noption $loption $poption -r "$tmpdir$b"/
((r--))
STRIP_TEMP=false unset uoption soption noption aoption loption poption
printf "${path[$r]}$c\t"
sleep 1
}
compresszip()
{
if [[ $r -lt 1 ]]
then
advzip -4 -a /tmp/"$b" $tmpdir"$b"/* > /tmp/null
else
advzip -0 -a /tmp/"$b" $tmpdir"$b"/* > /tmp/null
fi
mv -f /tmp/"$b" "$a"
}
compressgz()
{
if [[ $r -lt 1 ]]
then
advdef -4 -a /tmp/"$b" "$tmpdir$b"/* > /tmp/null
s2=$(getfilesize /tmp/"$b")
if [[ $s2 -lt $s ]]
then
mv -f /tmp/"$b" "$a"
fi
else
advdef -0 -a /tmp/"$b" "$tmpdir$b"/* > /tmp/null
mv -f /tmp/"$b" "$a"
fi
}
compress7z()
{
ne="7z"
if [[ $r -lt 1 ]]
then
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on /tmp/"${b%.*}".$ne "$tmpdir$b"/* > /tmp/null
s2=$(getfilesize /tmp/"${b%.*}".$ne)
if [[ $s2 -lt $s ]]
then
rm "$a"&&mv /tmp/"${b%.*}".$ne "${a%.*}".$ne
fi
else 7z a -mx=0 /tmp/"$b" "$tmpdir$b"/* > /tmp/null
mv -f /tmp/"$b" "$a"
fi
}
compressrar()
{
if [[ $r -lt 1 ]]
then
rar a -m0 /tmp/"$b" "$tmpdir$b"/* > /tmp/null
else
### à changer
rar a -m0 /tmp/"$b" "$tmpdir$b"/* > /tmp/null
fi
mv -f /tmp/"$b" "$a"
}
## option parser
if [[ $# -eq 0 ]]
then echo "usage : "
echo
echo 'opti.sh [-u|--ultra] [-s|--strip] [-n|-no-file-change] [-r|--recursive] [-nd|--no-png-decompress] [-nl|--no-log] file or folder (. for current folder)'
echo
echo '--ultra : max compression (only for png,executables) (defaut : off)'
echo '--strip : strip all metadata (only png/jpeg)'
echo "--no-file-change : don't change file type"
echo '--recursive : not only current folder'
echo "--no-png-decompress : don't decompress png in archives (sometimes better results)"
echo "--no-log : no logging"
echo
echo 'default :'
echo 'compress file for best size'
echo 'scan all content of archives recursivily'
echo 'strip all metadata of images only inside documents docx odt ... (so you keep informations on personnals photos)'
echo 'decompress compressed data (gz,png,zip, ...) in archive for best size of final archive'
echo 'change file type outside of archive with keeping compatibility bmp>png,xcf>xcf.gz,svg>svg.gz,wav>flac,zip>7z'
echo 'make a log (called opti.csv) in current directory who listing all changes'
echo 'work only with software available on system (skip file if the software not avaible), unar is recommanded'
echo 'try to preserve date/time of change of files'
echo 'remove all temporary files Desktop.ini, Thumbs.db, ...'
echo 'All changes are LOSSLESS for the data'
echo
echo 'install all software used :'
echo 'sudo apt-get install unar optipng jpegoptim gifsicle upx flac mp3packer leanify csstidy shrinksafe 7z rar ##mktools advcomp'
exit 0
fi
ULTRA=false STRIP=false FILECHANGE=true STRIP_TEMP=false ARCHIVE=false RECURSIVE=false PNGDECOMPRESS=true LOG=true
while [[ $# > 0 ]]
do
case "$1" in
-u|--ultra)
ULTRA=true
;;
-s|--strip)
STRIP=true
;;
-n|--no-file-change)
FILECHANGE=false
;;
-a|--archive)
ARCHIVE=true
;;
-r|--recursive)
RECURSIVE=true
;;
-nd|--no-png-decompress)
PNGDECOMPRESS=false
;;
-nl|--no-logging)
LOG=false
;;
*)
s="$1"
;;
esac
shift
done
## start
export tmpdir r path logfile
declare -a path
if [[ -z $s ]]
then
tput setaf 1
echo "folder or file $s not found"
tput setaf 7
exit 1
fi
if [[ -z $r ]]
then
r=0
path[0]=${s%/*}
[[ "$LOG" == "true" ]]&&logfile='opti.csv'
[[ "$LOG" == "true" ]]&&[[ ! -a "$logfile" ]]&&echo "level;filename;\"old size\";\"new size\"" > "$logfile"
tmpdir='/tmp/opti/'
mkdir -p $tmpdir
fi
orecursive='100'
[[ "$RECURSIVE" == "false" ]]&&orecursive='1'
find "$s" -maxdepth "$orecursive" -type f|while read a
do
orecursive=''
b=$(basename "$a")
if [[ $r == 0 ]]
then
if [[ $(grep "/" <<< "$a") ]]
then
c="/$b"
else
c=""
fi
else
c=${a/$tmpdir//}
fi
s=$(getfilesize "$a")
unset ne
not=false
m=$(stat -c "%Y" "$a")
case "$b" in
*.swp|wget.log|foobar*|*~|.netrwhist|Thumbs.db|desktop.ini|Desktop.ini|AlbumArt*.jpg|*.bak|*.old|*.log|*.tmp|._.DS_Store|"System Volume Information")
[[ "$LOG" == "true" ]]&&echo "$r;/"${path[$r]}$c/";$s;deleted" >> "$logfile"
printf "${path[$r]}$c\t$s\t"
tput setaf 1
echo "deleted"
tput setaf 7
rm -rf "$a"
continue
;;
esac
if [[ $s -eq 0 ]]
then
[[ "$LOG" == "true" ]]&&echo "$r;/"${path[$r]}$c/";$s;deleted" >> "$logfile"
printf "${path[$r]}$c\t$s\t"
tput setaf 1
echo "deleted"
tput setaf 7
rm -rf "$a"
continue
fi
printf "${path[$r]}$c\t"
case "${b##*.}" in
docx|DOCX|xlsx|XLSX|pptx|PPTX|epub|EPUB|odt|ODT|ods|ODS|odp|ODP|odb|ODB|odg|ODG|odf|ODF|jar|JAR|cbz|CBZ)
verify advzip||continue
extract
STRIP_TEMP=true
recur
compresszip
;;
7z|7Z)
verify 7z||continue
extract
recur
compress7z
;;
zip|ZIP)
extract
recur
if [[ $r -lt 1 ]]
then
verify 7z||continue
compress7z
else
verify advzip||continue
compresszip
fi
;;
rar|RAR)
extract
recur
if [[ $r -lt 1 ]]
then
verify 7z||continue
compress7z
else
verify rar||continue
compressrar
fi
;;
cbr|CBR)
verify rar||continue
extract
STRIP_TEMP=true
recur
compressrar
;;
gz|GZ|tgz|TGZ|xcfgz|XCFGZ|svgz|SVGZ)
verify advdef||continue
extract
recur
compressgz
;;
png|PNG|tif|TIF)
if [[ $r -lt 1 ]]||[[ "$PNGDECOMPRESS" == "false" ]]
then
verify optipng||continue
[[ "$STRIP" == "true" ]]&&soption='-strip all'
[[ "$ULTRA" == "true" ]]&&uoption='-o7'
optipng -quiet -preserve $uoption $soption "$a" > /tmp/null
soption='' uoption=''
else
verify advpng||continue
advpng -0 -z "$a"
fi
;;
bmp|BMP)
if [[ ! "$FILECHANGE" == "false" ]]&&[[ $r -lt 1 ]]
then
verify optipng||continue
ne=png
[[ "$STRIP" == "true" ]]&&soption='-strip all'
[[ "$ULTRA" == "true" ]]&&uoption='-o7'
optipng -quiet -preserve $uoption $soption "$a"
soption='' uoption=''
[[ -a "${a%.*}".$ne ]]&&rm -f "$a"
fi
;;
jpeg|JPEG|jpg|JPG)
verify jpegoptim||continue
[[ "$STRIP" == "true" ]]&&soption='--strip-all'
jpegoptim $soption "$a" > /tmp/null
soption=''
;;
xcf|XCF)
verify gzip||continue
if [[ "$FILECHANGE" == "false" ]]
then
not=false
else
if [[ $r -lt 1 ]]
then
ne=xcf.gz
gzip -c "$a" > "$tmpdir${b%.*}".$ne
advdef -4 -z "$tmpdir${b%.*}".$ne > /dev/null
mv "$tmpdir${b%.*}".$ne "${a%.*}".$ne&&rm -f "$a"
fi
fi
;;
exe|EXE|dll|DLL|sys|SYS|ocx|OCX|scr|SCR|cpl|CPL)
verify upx||continue
if [[ $r -lt 1 ]]
then
[[ "$ULTRA" == "true" ]]&&uoption='-9'
upx -qqq $uoption "$a"
uoption=''
else upx -d -qqq $uoption "$a"
fi
;;
gif|GIF)
verify gifsicle||continue
gifsicle --optimize=3 "$a" > "$tmpdir$b"&&s2=$(getfilesize "$tmpdir$b")&&if [[ $s2 -lt $s ]]
then mv "$tmpdir$b" "$a"
fi
;;
flac|FLAC)
verify flac||continue
flac --best "$a" -f -o "$tmpdir$b" > /tmp/null &&mv -f "$tmpdir$b" "$a"
;;
wav|WAV)
verify flac||continue
if [[ "$FILECHANGE" == "false" ]]
then
not=false
else
ne=flac
flac --best "$a" -f -o "${a%.*}".flac > /tmp/null &&rm -f "$a" > /tmp/null
fi
;;
mp3|MP3)
verify mp3packer||continue
mp3packer -f -z "$a"&&mv -f "${a%.*}"-vbr.mp3 "$a" > /tmp/null
;;
##doc|DOC|xls|XLS|chm|CHM)
##docprc.exe -b"$(dirname $a)" "$b" > /tmp/null
##;;
swf|SWF|xml|XML|xsl|XSL|xslt|XSLT|lua|LUA|rdb|RDB)
verify leanify||continue
leanify "$a" > /tmp/null
;;
php|PHP)
verify sed||continue
sed 's|/\*|\n&|g;s|*/|&\n|g' "$a" | sed '/\/\*/,/*\//d' > "$tmpdir$b"&&mv -f " $tmpdir$b" "$a"
;;
css|CSS)
verify csstidy||continue
csstidy "$a" "$tmpdir$b" > /tmp/null &&mv -f "$tmpdir$b" "$a"
;;
js|JS)
verify shrinksafe||continue
shrinksafe "$a" > "$tmpdir$b"&&s2=$(getfilesize "$tmpdir$b")&&if [[ $s2 -lt $s ]]
then mv $tmpdir"$b" "$a"
fi
;;
svg|SVG)
verify scour.py||continue
scour.py -i "$a" -o "$tmpdir$b" 2> /dev/null
if [[ ! "$FILECHANGE" == "false" ]]&&[[ "$r" -lt 1 ]]
then
ne=svgz
gzip -c "$tmpdir$b" > "$tmpdir${b%.*}".$ne
advdef -4 -z "$tmpdir${b%.*}".$ne > /dev/null
mv $tmpdir"${b%.*}".$ne "${a%.*}".$ne&&rm -f "$a"
else
mv $tmpdir"$b" "$a"
fi
;;
html|HTML)
verify htmlcompressor.jar||continue
htmlcompressor.jar "$a" > "$tmpdir$b" &&mv "$tmpdir$b" "$a"
;;
mkv|MKV)
verify mkclean||continue
mkclean --optimize "$a" "$tmpdir$b"&&mv $tmpdir"$b" "$a"
;;
##pdf|PDF)
##verify pdfsizeopt.py
##pdfsizeopt.py --use-multivalent=no "$a" "$tmpdir$b" 2> /dev/null &&mv /tmp/##opti/"$b" "$a"
##rm -f pso*
esac
if [[ $ne != "" ]]
then
s2=$(getfilesize "${a%.*}".$ne)
touch -t $m "${a%.*}".$ne 2> /dev/null
else
s2=$(getfilesize "$a")
touch -t $m "$a" 2> /dev/null
fi
if [[ $s != $s2 ]]
then
tput setaf 2
echo "$s $s2"
[[ "$LOG" == "true" ]]&&echo "$r;\"${path[$r]}$c\";$s;$s2" >> "$logfile"
else
tput setaf 3
[[ $not == false ]]&&echo "nothing to do"
[[ $not == true ]]&&echo "already optimized"
fi
tput setaf 7
((t1+=$s))
echo $t1 > ${tmpdir}t1
((t2+=$s2))
echo $t2 > ${tmpdir}t2
done
if [[ $r == 0 ]]
then
t1=$(cat ${tmpdir}t1)
t2=$(cat ${tmpdir}t2)
rm -rf "$tmpdir"
unset path r tmpdir
printf "\nTOTAL :\t%d %d\n" $t1 $t2
fi
Dernière modification par Compte anonymisé (Le 18/05/2016, à 10:34)