Need to convert hundreads of pdf files across several folders. pdf2djvu gui is junk on windows and always crashes after a couple of conversions.

Taking this code of which I am working from

for file in *.pdf; do pdftotext "$file" "$file.txt"; done

I normally run pdf2djvu like this: pdf2djvu -o *.djvu *.pdf

Using what's below gives me: I Won't write DjVu data to terminal

for file in *.pdf; do pdf2djvu "$file" "$file.djvu"; done

And for: file in *.pdf; do pdf2djvu -o "$file" "$file.djvu"; done

Unable to load document PDF error: Couldn't open file*.pdf.djvu: random unknown characters

And for: for file in *.pdf; do "pdf2djvu -o" "$file" "$file.djvu"; done

pdf2djvu -o: command not found

And for: for file in .pdf; do "pdf2djvu -o *.djvu *.pdf" "$file" "$file.djvu"; done bash: pdf2djvu -o *.djvu *.pdf: No such file or directory


-o is output options. Output filename should follow after it. So this works for me:

for file in *.pdf; do pdf2djvu -o "$file.djvu" "$file"; done
  • That code gives me PDF error: May not be a PDF file (continuing anyway) PDF error: Couldn't find trailer dictionary PDF error: Couldn't read xref table Unable to load document Will google now and see if I get an answer and edit if I find anything – – user140393 Mar 20 '13 at 8:48
  • Forgot to update this a couple days one of my earlier commands caused it to corrupt the pdf. Code works fine. Thanks :D – user140393 Mar 25 '13 at 7:24
for file in *.pdf; do pdf2djvu -o "$file.djvu" "$file"; done

Will convert all files to djvu. However, the new files will be named with a .pdf.djvu extension.

To end up with conversion to djvu and a .djvu extension use:

for file in *.pdf; do pdf2djvu -o "${file%.pdf}.djvu" "$file"; done

This will strip off the .pdf before appending the .djvu to the filename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.