Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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