Removes all metadata from one or more PDF files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
997 B

# A very simple script by Max Mehl:
# Removes all metadata from a PDF file located in the same dir like the script
# This happens by the usage of pdftk, a powerful command line tool on GNU/Linux
# change to directory where the script resides if tool is called by cron
cd "$(dirname "$(readlink -f "$0")")"
ls *.pdf > /dev/null 2>&1
if [ "$?" = "0" ]; then
mkdir ./temp # create temporary directory
cp ./*.pdf ./temp
echo "No files found"
exit 1
# Replace spaces with underscores
for FILE in ./temp/*.pdf; do
rename "s/ /_/g" "$DATEI" > /dev/null 2>&1;
for i in $( find ./temp -type f -name "*.pdf" ); # filename with path in $i
FILENAME=`basename $i` # filename without path
# Dump data in temporary file
pdftk $i dump_data output $i.meta
sed 's/InfoValue:.*/InfoValue:/g' $i.meta > $i.meta.clean
pdftk $i update_info $i.meta.clean output $FILENAME # Update Metadata from cleaned metafile and write to original file
rm -r ./temp