This worked for me:
An Illustrator script to help you in the mobile world
I created this Adobe Illustrator Script to help me export PNGs from layers for different densities (iOS Retina Display, Android Devices, etc).
The script asks for 3 values in sequence:
The folder where you want to save the files.
The scale factor 1 = 100% = 160dpi = mdpi, 2 = 200% = 320dpi = retina display (these values are only valid if you designed for 160dpi aka mdpi).
A suffix if you want to use one, e.g., @2x for retina display in iOS. You can also leave it empty if you don’t want a suffix or if you are exporting to android or iOS non-retina.
Locked layers visibility will be ignored and also they will not be exported.
For example, this can be used to keep global layers visibility or guide layers from being exported.