Results 1 to 5 of 5

Thread: Shell Script Help

  1. #1
    Join Date
    Nov 2009
    Beans
    28

    Shell Script Help

    Hi all,

    I'm trying to write a shell script, both as practice as I've never written one before, and also to convert a whole load of .eps image files into .pdf for LaTeX purposes.

    So...I have a script, which doesn't work. I actually copied most of it from what I've found online, but for some reason it won't work and I want to know why.

    So this is my script...

    #!/bin/bash
    filelist=`(find . -name \*.eps)`
    for file in $filelist;
    do
    ps2pdf -dEPSCrop $file
    echo 'Converted $file into pdf.'
    done

    which finds a list of files ending in .eps, and then runs a for loop, converting each one in turn.

    I get a complaint that the for loop fails on line 3. If I debug the script, the filelist appears to pick up the files in the folder, but when it lists them it looks like this...

    filelist = './a.eps
    ./b.eps
    ./c.eps
    '/d.eps (that apostrophe is intentional)

    Since I don't know much about writing shell scripts, I don't know what is causing the problem. Presumably the for loop doesn't like the form that I've given the files in. The 'misplaced' apostrophe looks suspect to me, but again, I don't know if that's normal.

    Thanks for your help in advance.

  2. #2
    Join Date
    Sep 2006
    Beans
    7,191
    Distro
    Lubuntu Development Release

    &&

    Take it fewer steps at a time, but the problem is probably with ps2pdf. Does it exist?

    Code:
    #!/bin/bash
    filelist=`(find . -name \*.eps)`
    for file in $filelist;
    do
    ps2pdf -dEPSCrop $file && echo 'Converted $file into pdf.' || echo "Conversion of $file failed."
    done

  3. #3
    Join Date
    Nov 2009
    Beans
    28

    Re: Shell Script Help

    Yes, ps2pdf exists and works. If I run the command itself then I can convert each file at a time.

  4. #4
    Join Date
    Oct 2012
    Beans
    1

    Re: Shell Script Help

    Try,

    #!/bin/bash
    filelist=`(find . -name \*.eps)`

    for file in $filelist;
    do
    epstopdf $file
    echo 'Converted '$file' into pdf.'
    done

  5. #5
    Join Date
    Feb 2011
    Location
    /Earth/India/Patna
    Beans
    147
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Shell Script Help

    Try this one

    #!/bin/bash
    for file in *.eps
    do
    ps2pdf -dEPSCrop $file
    echo 'Converted $file into pdf.'
    done
    Last edited by Abhinav Kumar; October 28th, 2012 at 12:08 AM.

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
  •