# Lua scripting

**URL:** https://discourse.orthanc-server.org/t/lua-scripting/2768
**Category:** Google Groups archive
**Created:** [January 16, 2022, 1:50am UTC](https://discourse.orthanc-server.org/t/lua-scripting/2768 "2022-01-16T01:50:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Wisdom\_James\_Murombo](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/w/a9adbd/32.png) [@Wisdom\_James\_Murombo](https://discourse.orthanc-server.org/u/Wisdom_James_Murombo)
#### Post date: [January 16, 2022, 1:50am UTC](https://discourse.orthanc-server.org/t/lua-scripting/2768/1 "2022-01-16T01:50:42Z")

</div>

I want Orthanc to auto route dicom files to a specific directory in my computer. I don’t know what parameter I have to put in the quotes written sample below so that the files will be routed to my desired directory:

function OnStoredInstance(instanceId, tags, metadata)  
SendToModality(instanceId, ‘sample’)  
end

Have tried to put the path to the directory but nothing is working. I am only reiving the error that it Couldn’t read data from file “route\_dicoms.lua”.

How can I solve this?

---

<div class="post-metadata">

### Author: ![Brice\_Mitchell](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Brice\_Mitchell](https://discourse.orthanc-server.org/u/Brice_Mitchell)
#### Post date: [January 16, 2022, 8:36pm UTC](https://discourse.orthanc-server.org/t/lua-scripting/2768/2 "2022-01-16T20:36:54Z")

</div>

That script is used to auto route to another DICOM modality. You would need to use something like the WriteToDisk.lua which is included in the Orthanc source code.

[https://hg.orthanc-server.com/orthanc/file/tip/OrthancServer/Resources/Samples/Lua/WriteToDisk.lua](https://hg.orthanc-server.com/orthanc/file/tip/OrthancServer/Resources/Samples/Lua/WriteToDisk.lua)
