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"; doneWill 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"; doneThis will strip off the .pdf before appending the .djvu to the filename.