Skip to content

Instantly share code, notes, and snippets.

@marlosirapuan
Last active March 2, 2016 00:32
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 marlosirapuan/81858bee98fad434ca01 to your computer and use it in GitHub Desktop.
Save marlosirapuan/81858bee98fad434ca01 to your computer and use it in GitHub Desktop.
converte arquivos *.jpg das pastas em .pdf
#!/bin/bash
### instala imagemagik
# brew install imagemagick
# convert *.jpg output.pdf
### dentro da pasta
# sh twd_convert.sh .
execute_convert() {
for i in "$1"/*;do
if [ -d "$i" ];then
echo "dir: $i"
cd $i > /dev/null
DIR_NAME=${PWD##*/}
echo "dirname: $DIR_NAME"
convert *.jpg TWD-$DIR_NAME.pdf
cd - > /dev/null
elif [ -f "$i" ]; then
echo "arq: $i"
fi
done
}
path=""
if [ -d "$1" ]; then
path=$1;
else
path="./"
fi
echo "base: $path"
#output_path="$path/output"
#mkdir -p $output_path
execute_convert $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment