Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am unsure of what part of my command is improper, but I am given no error and only a usage page when entering the following:

/usr/bin/chm2pdf --book *.chm *.pdf

and

/usr/bin/chm2pdf --book *.chm [*.pdf]

More to the point, I have a directory 100+ .chm files I was tasked with converting, and the usage for batch converting was practically nonexistent in any of the documentation, so a wildcard may not be the way to go, evidently.

Here is the message I am provided:

#/usr/bin/chm2pdf --book *.chm [*.pdf]
Usage:
        /usr/bin/chm2pdf [options] input_filename [output_filename]

Options:
...

My question, more specifically, refers to batch conversion, as I used the examples above to convert single .chm files properly, and in the description of the utility, batch conversion is evidently a feature.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Looks like your syntax is right, but you'll need to iterate through the items for a batch job.

If they're all in the same folder, something as simple as this script should work:

#!/usr/bin/env bash

for i in `find . -maxdepth 1 -type f -name "*.chm"`; do
    /usr/bin/chm2pdf --book ${i} `echo ${i} | sed 's/.chm/.pdf/'`
done

That should be closer to what you need.

To explain it:

1) You're listing all matching files to the type *.chm at a max depth of 1 folder (the folder you're in).
2) For each of those, run /usr/bin/chm2pdf with ${i} being the individual item's name. Then replacing the file name for the out-file from "whatever.chm" to "whatever.pdf".
3) Then done.

share|improve this answer
    
Thanks, looks like it's working; the titles of the .chm files seem to be throwing it off, but other than that, seems to be working. –  tony_perkis666 Jan 30 '13 at 1:11
    
What do you mean? Something we can adjust to help you out more? –  nerdwaller Jan 30 '13 at 1:13
1  
I just reordered the first line to for i in find . -maxdepth 1 "*.chm" -type f -name; do (to resolve a seemingly innocuous warning) then I changed my original line from --book to --webpage. Between all that it seems to be working fine now. Thanks again. –  tony_perkis666 Jan 30 '13 at 1:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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