uploadFiles.sh 827 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #copy content of directory to orthanc
  2. #works for orthanc 1.12.0, not for 1.6.1
  3. if [ $# -lt 1 ] ; then
  4. echo $#;
  5. echo Usage $0 DIR networkConfig;
  6. exit 0;
  7. fi;
  8. CFG=$2;
  9. USER=$(jq -r ".orthanc.user" $CFG);
  10. PASSWORD=$(jq -r ".orthanc.password" $CFG);
  11. SERVER=$(jq -r ".orthanc.server" $CFG);
  12. CURL="curl -u $USER:$PASSWORD"
  13. arr=($(echo $1/*.zip));
  14. Nall=${#arr[@]};
  15. N=$Nall
  16. echo Loading $N/$Nall;
  17. i=0
  18. for ((j=0;j<Nall;j++)) ; do
  19. #ls ${arr[j]};
  20. R=$($CURL -X POST $SERVER/instances --data-binary "@${arr[j]}" |jq -r ".[] | .Status");
  21. for x in $R ; do
  22. #echo $x;
  23. if [ $x == "AlreadyStored" ] ; then
  24. #echo Done
  25. break;
  26. else
  27. #echo New
  28. i=$((i+1));
  29. break;
  30. fi;
  31. done;
  32. if [ $i -eq $N ] ; then
  33. #echo "[$i/$N] Done"
  34. break;
  35. else
  36. #echo "[$i/$N] Not done"
  37. :
  38. fi;
  39. echo "Done [$j/$Nall, new $i]"
  40. done;