Why you need a script? Go to File-->Export and choose "dxf".
I need of every layer a seperate dxf-file.
The results are imported in a CAD system and than an export error (wrong setting) wil be visible.
So I want to automate the export, so that every one can generate the same output.