Skip to content

Instantly share code, notes, and snippets.

@vvakame
Created June 10, 2011 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvakame/1018575 to your computer and use it in GitHub Desktop.
Save vvakame/1018575 to your computer and use it in GitHub Desktop.
#!/bin/bash
pdf2zip(){
file_path="$1"
file_name="${file_path##*/}"
name="${file_name%.pdf}"
extension="${file_path##*.}"
if [ "${extension}" != "pdf" ]
then
echo "${file_path} is not PDF...."
return 0
fi
echo "${file_name} is PDF!! convert..."
mkdir "${name}" > /dev/null
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r300 -sOutputFile="${name}"/\%003d.jpg "${file_path}" > /dev/null
zip -r "${name}.zip" "${name}/" > /dev/null
rm -rf "${name}" > /dev/null
}
for arg in "$@"
do
pdf2zip "${arg}"
done
@vvakame
Copy link
Author

vvakame commented Jun 10, 2011

使い方
find . -print0 | xargs -0 -n 1 ./pdf2zip.sh
だいたいこんなん。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment