-1

My goal is a single file of documents in JSON format, that would come from 50-100 MS Word or PDF documents.

Is there a way to supply multiple documents to the "convert_document" command? I've tried using curl to supply multiple .pdf or *.doc files like this:

 curl -u
  "username":"password" 
  -F "config={\"conversion_target\":\"ANSWER_UNITS\"};type=application/json" 
  -F "file=@\*.doc;type=application/msword" -X POST
 "https://gateway.watsonplatform.net/document-conversion-experimental/api/v1/convert_document"

Unfortunately, this gives me an error: curl: (26) couldn't open file "*.doc" I have also tried -F "file=@file1.doc,file2.doc,file3.doc" but that gives errors as well.

ralphearle
  • 1,696
  • 13
  • 18

1 Answers1

0

The document conversion service only accepts one file at a time, but you can call it multiple times and concatenate the results.

 #!/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
ralphearle
  • 1,696
  • 13
  • 18