User Tools

Site Tools


linux:linux_hacks

Linux hacks

Merge 2 PDFs together from Nautilus http://gnome-look.org/content/show.php/?content=83871 requires pdftk https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

#!/bin/bash
ifs=$IFS
IFS='\
'
PDFARGUMENTS=""
fpaths=`echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sort`
for file in $fpaths
do
  if [ -f "$file" ]; then
	base=${file%.*}
	ext=${file##*.}
	if [ "$ext" == "pdf" ]; then
	    PDFARGUMENTS="$PDFARGUMENTS \"$file\""
	    pdfdir=`dirname "$file"`
	fi
  fi
done
 
szSavePath=$(zenity --file-selection --save --confirm-overwrite);echo "$szSavePath"
 
if [ -n "$PDFARGUMENTS" ]; then
    eval pdftk "$PDFARGUMENTS" cat output "\"$szSavePath\""
fi
IFS=$ifs
linux/linux_hacks.txt · Last modified: 2014/11/23 01:33 by igorkagan