I'm trying to convert html files to pdf files using the following command line

for file in *.html; do /usr/sbin/cupsfilter “$file” > $file.pdf; done

But I got the message as below and empty pdf files

cupsfilter: Unable to determine MIME type of ““??”.**

Could you please point out the syntax error that I made in command line.

I'm currently using Mac OS X 10.11.3

  • 1
    Wrong and missing quotes? At least for file in *.html ; do /usr/sbin/cupsfilter "$file" > "$file".pdf ; done works! – klanomath Mar 17 '16 at 21:39
  • Thanks klanomath. But I still get the same error message as mentioned above and no pdf output files at all. – Bob Mar 17 '16 at 23:09
  • I guess your website_name.html.pdf is empty, am I right? – Bob Mar 17 '16 at 23:22
  • my pdf files is zero bytes. No clue! – Bob Mar 17 '16 at 23:24
  • Hmm remove any 0 byte file containing hmtl (or htm) before executing the command; even those with the name *.html.pdf – klanomath Mar 17 '16 at 23:26

Quotes: “ versus "

You are using 'typographers' quotes instead of 'regular' quotes. Try this line:

for file in *.html; do /usr/sbin/cupsfilter "$file" > "$file".pdf; done

note the difference in quotation

  • Thanks CousinCocaine for pointing out this typo. I just figured it out myself a minutes ago. – Bob Mar 18 '16 at 0:48
  • I wish I could read your answer sooner than I figured it out myself :). It was driving me nut. Again, thanks for your help! – Bob Mar 18 '16 at 0:55
  • @Bob for the correct use of quotes read: unix.stackexchange.com/questions/118433/… – CousinCocaine Mar 18 '16 at 5:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .