Last active
March 14, 2020 13:52
-
-
Save amio/a4f810265ffa0b8d2a38c54227e83289 to your computer and use it in GitHub Desktop.
Remove ''www.it-ebooks.info" from pdf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source_dir=$1; | |
find "$1" -type f -name "*.pdf" -print0|while read -d $'\0' file; | |
do | |
if [ `strings "$file"|grep -c "www.it-ebooks.info"` -gt 0 ]; | |
then | |
echo "$file"; | |
cp "$file" /tmp/1.pdf; | |
script=$(cat <<'EOF' | |
use strict; | |
use warnings; | |
open(my $in, '<', '/tmp/1.pdf') | |
or die "Cannot open input.txt: $!"; | |
open(my $out, '>', '/tmp/2.pdf') | |
or die "Cannot open output.txt: $!"; | |
while (<$in>) { | |
print $out $_ unless /www.it-ebooks.info/; | |
} | |
close($in); | |
close($out); | |
EOF | |
) | |
/usr/bin/perl -e "$script" | |
mv -v /tmp/2.pdf "$file"; | |
rm /tmp/1.pdf | |
fi; | |
done | |
# Usage: | |
# chmod +x rm-ite.sh | |
# ./rm-ite.sh ~/pdf-dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...just great.