How to convert multiple documents using the Document Conversion service ina script bash?

前端 未结 1 441
暗喜
暗喜 2021-01-20 03:41

How can I convert more than one document using the Document Conversion service.

I have between 50-100 MS Word and PDF documents that I want to convert using the con

相关标签:
1条回答
  • 2021-01-20 04:08

    The service only accept one file at a time, but you can call it multiple time.

    #!/bin/bash
    USERNAME="<service-username>"
    PASSWORD="<service-password>"
    URL="https://gateway.watsonplatform.net/document-conversion-experimental/api/v1/convert_document"
    DIRECTORY="/path/to/documents"
    for doc in *.doc
    do
      echo "Converting - $doc"
      curl -u "$USERNAME:$PASSWORD" \
      -F 'config={"conversion_target":"ANSWER_UNITS"};type=application/json' \
      -F "file=@$doc;type=application/pdf" "$URL"
    done
    

    Document Conversion documentation and API Reference.

    0 讨论(0)
提交回复
热议问题