Menu

*djvm* problem parsing wildcard argument

Fooby
2014-09-04
2014-09-05
  •  Fooby

    Fooby - 2014-09-04

    I am trying to create a multi-page djvu from single-page ones with djvm in a bash script. I tried using the * wildcard:

    djvm -c "dir1/dir2/My.djvu" "dir1/dir2/djvus/*.djvu"
    

    but I get:

    error: *** [1-11711] Failed to open '*.djvu': No such file or directory.
    

    BTW I tried this with and without quotes.

    So I instead first created the output file My.djvu using the first file in dir1/dir2/djvus:

    d="dir1/dir2/djvus"
    f=$(ls "$d" | head -1) # first file in directory
    djvm -c "dir1/dir2/My.djvu" "${d}/${f}" # create djvu with first page
    

    And then inserted each page one by one:

    for f in dir1/dir2/djvus/*.djvu
    do
        # filename.ext split from full path
        p="${f##*/}"
        echo "${p}-->My.djvu"
        djvm -i "dir1/dir2/My.djvu" "${f}" # insert pages one by one
    done
    

    And finally deleted the first page which is now a duplicate:

    djvm -d "dir1/dir2/My.djvu" 1 # delete first page which is a duplicate
    

    This works OK but it is ridiculously slow because the file gets rewritten from scratch each time.

    What is the proper syntax needed to get the wildcard correctly parsed?

     

    Last edit: Fooby 2014-09-04
  •  Fooby

    Fooby - 2014-09-05

    OK, I found what I can only consider a workaround, not really a solution, which IMO would require some modification of the design of this tool.

    f=$(echo dir1/dir2/djvus/*.djvu)
    djvm -c "dir1/dir2/My.djvu" $f
    

    This only works if there are no spaces in directory and file names.

    I created an 862MB multi-page djvu from 1,040 single djvus and it took over 3 hours using the loop method. It took less than a minute using this kludge. But hey, if it works…

     

Log in to post a comment.

MongoDB Logo MongoDB