How to use shell loop using lowriter

Asked

Viewed 24 times

0

I’m trying to run the lowriter(generate PDF) loop, this way:

#!/bin/sh

ROOT_DIRECTORY="docs"

function count_files()
{
    ls -lR $ROOT_DIRECTORY/*.doc | wc -l
}

function get_number_folders()
{
    expr $(count_files) / 100 + 1
}

function create_folders_and_fill_with_files()
{
    for num in $(seq 1 $(get_number_folders))
    do
        #mkdir $ROOT_DIRECTORY/$num
        mv `ls $ROOT_DIRECTORY/*.doc | head -100` $ROOT_DIRECTORY/$num/
        convert_to_pdf $ROOT_DIRECTORY $num
    done
}

function convert_to_pdf()
{
    lowriter -convert-to pdf --outdir ./docs/ $1/$2/*.doc --headless
    set -x
}

create_folders_and_fill_with_files

Apparently the command is right, the only problem is that it runs 1 single time and stops, does not run again, as I can run the lowriter several times?

Grateful

1 answer

0

Maybe you’re popping in the lowriter? Try redirecting the stderr to the stdout to see what may be occurring:

lowriter -convert-to pdf --outdir ./docs/ $1/$2/*.doc --headless 2>&1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.