Results 1 to 3 of 3

Thread: convert pdf script problem

  1. #1
    Join Date
    Jul 2006
    Location
    Hungary
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    Post convert pdf script problem

    Hi all I'm in the process of creating a script to batch process a bunch of pdf in to images with imagemagick this is what she looks like so far

    Code:
    #!/bin/bash
    
    IFS=$'\n'
    
    TESTARRAY=( $(find . -type f -name "*full.pdf") )
    
    for (( i=0; i<${#TESTARRAY[@]}; i++ )); do
      (convert ${TESTARRAY[i]} bc.png);
    done
    my problem is that the script dumps all of the finished images in the working dir of the script basically overwriting the last set created how would I modify this script to output the images to the same dir that the original pdf was in.

    thanks for any help.
    Ubuntu user number # 29587

    I'm Jet Black, 36 years old. I'm often told I don't look 36, but you shouldn't judge people based on appearances... or on how much hair they have.

  2. #2
    Join Date
    Nov 2008
    Beans
    479
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: convert pdf script problem

    Code:
    SOURCEDIR=/home/cowboy
    
    find $SOURCEDIR -type f -iname '*.pdf' | while read SourceFile; do
      PNGFile="${SourceFile%.pdf}.png"
      if [[ ! -e "$PNGFile" ]]; then
        convert "$SourceFile" "$PNGFile"
      fi
    done
    5127d464-4548-4993-a138-f546f2fd2a33

  3. #3
    Join Date
    Jul 2006
    Location
    Hungary
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    Talking Re: convert pdf script problem

    Quote Originally Posted by arrange View Post
    Code:
    SOURCEDIR=/home/cowboy
    
    find $SOURCEDIR -type f -iname '*.pdf' | while read SourceFile; do
      PNGFile="${SourceFile%.pdf}.png"
      if [[ ! -e "$PNGFile" ]]; then
        convert "$SourceFile" "$PNGFile"
      fi
    done
    well "arrange" rearranged my script fu the only problem I had was the images were in a directory with a space in the name solved buy trans to new dir and back after bit messy and very un fu but time is of the essence.

    thanks arrange will add that to my script lib for later perusal
    Ubuntu user number # 29587

    I'm Jet Black, 36 years old. I'm often told I don't look 36, but you shouldn't judge people based on appearances... or on how much hair they have.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •