There are several ways to obtain it:
1 ) Modify the "New Doc action button" to fill a field in the new doc
with the name of the current folder
2 ) Modify the "New Doc action button" to write in the environment e
variable whith the name of current folder. A field in the doc will get
that value from the environment
3 ) you can Write the environment variable with the folder name every
time you open a folder.
I hope this helps you. Write if not