# Export CINE and images to a folder organized by patient or study.

**URL:** https://discourse.orthanc-server.org/t/export-cine-and-images-to-a-folder-organized-by-patient-or-study/2448
**Category:** Google Groups archive
**Created:** [May 20, 2021, 7:36pm UTC](https://discourse.orthanc-server.org/t/export-cine-and-images-to-a-folder-organized-by-patient-or-study/2448 "2021-05-20T19:36:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Terry\_Hauschulz](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@Terry\_Hauschulz](https://discourse.orthanc-server.org/u/Terry_Hauschulz)
#### Post date: [May 20, 2021, 7:36pm UTC](https://discourse.orthanc-server.org/t/export-cine-and-images-to-a-folder-organized-by-patient-or-study/2448/1 "2021-05-20T19:36:03Z")

</div>

I would like to have images as JPG and CINE’s as MP4 or WMV all organized into a patient folder or a study folder. Is there a way to do this export out of Orthanc, and better yet automatically as the images arrive in Orthanc. Currently using Postgres DB which works great.

Thank you, Terry

---

<div class="post-metadata">

### Author: ![jodogne](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/jodogne/32/1511_2.png) [@jodogne](https://discourse.orthanc-server.org/u/jodogne)
#### Post date: [May 28, 2021, 9:18am UTC](https://discourse.orthanc-server.org/t/export-cine-and-images-to-a-folder-organized-by-patient-or-study/2448/2 "2021-05-28T09:18:44Z")

</div>

You have multiple solutions to this end:

- Use a Lua script, cf. “OnStoredInstance()”: [https://book.orthanc-server.com/users/lua.html](https://book.orthanc-server.com/users/lua.html)
- Use an external script (e.g. in Python, Java, C#…) that uses the REST API of Orthanc, notably by monitoring the “/changes” route: [https://book.orthanc-server.com/users/rest.html](https://book.orthanc-server.com/users/rest.html)
- Create a Python plugin that listens to events in Orthanc as new instances are received: [https://book.orthanc-server.com/plugins/python.html#accessing-the-content-of-a-new-instance](https://book.orthanc-server.com/plugins/python.html#accessing-the-content-of-a-new-instance)

The REST API of Orthanc allows you download JPEG previews as follows:

$ curl -H ‘Accept: image/jpeg’ [https://demo.orthanc-server.com/instances/58298b2d-c272f374-a0dac287-46d36eec-bbd398c6/preview](https://demo.orthanc-server.com/instances/58298b2d-c272f374-a0dac287-46d36eec-bbd398c6/preview) \> preview.jpg

You can download a MPEG2 or H.264 video embedded inside a DICOM instance as follows:

$ curl [http://localhost:8042/instances/e465dd27-83c96343-96848735-7035a133-1facf1a0/frames/0/raw](http://localhost:8042/instances/e465dd27-83c96343-96848735-7035a133-1facf1a0/frames/0/raw) \> video.mp4

HTH,

Sébastien-
