pdf2djvu conversion of all files in a folder

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

2 Answers

-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
2
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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like