multiple selected files
should/could this be made to work for selections of multiple files?
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello Steve, and thanks for your interest.
If Compress PDF had a roadmap, multiple files support would definitely be there. Unfortunately, this would take quite an amount of work and changes to the present script, so I'm not really sure when this is gonna happen - maybe for Compress PDF 2.0!
Regards
Revision history for this message
|
#3 |
Here is a multi file version I've sent to Ricardo by email as I don't use BZR :
#! /bin/bash
# AUTHOR: (c) Ricardo Ferreira
# NAME: Compress PDF 1.4
# DESCRIPTION: A nice Nautilus script with a GUI to compress and optimize PDF files
# REQUIRES: ghostscript, poppler-utils, zenity
# LICENSE: GNU GPL v3 (http://
# WEBSITE: https:/
# Messages
# English (en-US)
error_nofiles="No file selected."
error_
error_
error_nopdf="The selected file is not a valid PDF archive."
label_
label_
optimization_
level_
level_
level_low="Low Quality"
level_high="High Quality"
level_color="High Quality (Color Preserving)"
job_done="has been successfully compressed"
filename_
case $LANG in
pt* )
# Portuguese (pt-PT)
error_
error_
error_
error_nopdf="O ficheiro seleccionado não é um ficheiro PDF válido."
label_
label_level="Por favor escolha um nível de optimização abaixo."
optimization_
level_
level_
level_low="Baixa Qualidade"
level_high="Alta Qualidade"
level_color="Alta Qualidade (Preservação de Cores)"
job_done="foi comprimido com sucesso"
filename_
es* )
# Spanish (es-AR) by Eduardo Battaglia
error_
error_
error_
label_
label_level="Por favor escoja un nivel de optimización debajo."
optimization_
level_
level_
level_low="Baja calidad"
level_high="Alta calidad"
level_color="Alta calidad (Preservación de Colores)"
filename_
cs*)
# Czech (cz-CZ) by Martin Pavlík
error_
error_
error_
label_
label_
optimization_
level_
level_
level_low="Nízká kvalita"
level_
level_
filename_
fr*)
# French (fr-FR) by Astromb
error_
error_
error_
error_nopdf="Le fichier que vous avez sélectionné n'est pas un PDF valide."
label_
label_
optimization_
level_
level_
level_low="Basse qualité"
level_high="Haute qualité"
level_
filename_
zh_CN*)
# Simplified Chinese (zh_CN) by TualatriX Chou
error_
error_
error_
error_
label_
label_
optimization_
level_
level_
level_low="低品质"
level_high="高品质"
level_
filename_
ar*)
# Arabic (ar) by Mohammed hasan Taha
error_nofiles="لم يتم اختيار ملف"
error_
error_
error_
label_
label_
optimization_
level_
level_screen="عرض للشاشة فقط(الدرجة الأكثر انخفاضا)"
level_low="جودة منخفضة"
level_high="جودة مرتفعة"
level_color="جودة عالية جدا"
filename_
ml_IN*)
# Malayalam (ml_IN) by Hrishikesh K B
error_
error_
error_
error_
label_
label_
optimization_
level_
level_
level_low="കുറഞ്ഞ നിലവാരം"
level_high="കൂടിയ നിലവാരം "
level_
filename_
esac
VERSION="1.4.1"
ZENITY=$(which zenity)
# Check if Ghostscript is installed
GS="/usr/
if [ ! -x $GS ]; then
$ZENITY --error --title="Compress PDF "$VERSION"" --text=
exit 0;
fi
# Check if the user has selected any files
if [ $# -eq 0 ]; then
$ZENITY --error --title="Compress PDF "$VERSION"" --text=
exit 0;
fi
# Ask the user to select a compressing format
selected_
if [ -z "$selected_level" ]; then
$ZENITY --error --title="Compress PDF "$VERSION"" --text=
exit 0;
fi
# Select the optimization level to use
case $selected_level in
;;
;;
;;
;;
;;
esac
# Choose output file name
temp_filename=
if [ $# -eq 1 ] ; then
pdf_file=
suggested_
output_
if [ "$?" = 1 ] ; then
exit 0;
fi
fi
for arg in $*
do
if [ $# -ne 1 ] ; then
pdf_file=
output_
fi
# Check if the selected file is a PDF
mimetype=$(file -b -i "$arg")
if [ -z "`echo $mimetype | grep -i 'pdf' `" ]; then
$ZENITY --error --title="Compress PDF "$VERSION"" --text=
exit 0;
fi
# Extract metadata from the original PDF
pdfinfo "$arg" | sed -e 's/^ *//;s/ *$//;s/ \{1,\}/ /g' -e 's/^/ \//' -e '/CreationDate/,$d' -e 's/$/)/' -e 's/: / (/' > .pdfmarks
sed -i '1s/^ /[/' .pdfmarks
sed -i '/:)$/d' .pdfmarks
echo " /DOCINFO pdfmark" >> .pdfmarks
# Execute ghostscript while showing a progress bar
(echo "0" ;
gs -sDEVICE=pdfwrite -dCompatibility
rm .pdfmarks
echo "100") | (if `$ZENITY --progress --pulsate --auto-close --title="Compress PDF "$VERSION""`;
done
Hope it helps, regards
Revision history for this message
|
#4 |
Correcting my own mistake ;)
the line : for arg in $*
should be : for arg in "$@"
to avoid problems with space characters in filenames.
Regards
Revision history for this message
|
#5 |
Compress PDF 1.5 allows you to select multiple files (thanks to oriolpont and edouardst).
Can you help with this problem?
Provide an answer of your own, or ask Steve Copeland for more information if necessary.