Save the studies in the directory by PatientsID

I need to save the dicom images that i recieved in format like:
D:/Orthanc/{PatID}/{Study_uid}/…
I just see the Orthanc saved the studies in lots of folders.
I tried to use Lua but it can not catch the path by Rest API

Any one know how to solve this issue.

Thank you very much bacrickboom.
It worked but the study removed from Orthanc because of you use " Delete(instanceId) ".
Can we handel this by update or reinsert the new path of study inside the orginal database or inside Mysql if we use it.
What I have to add in Lua script.

You are welcome.
What you want to achieve is not doable with Orthanc (at least out of the box).