In order to use the command EXPORT / LAYERS to FILES in a script (and Automation). It would be interesting to add a variable [FILE_NAME] to the file name prefix to process this command in batch.
Thus each LAYER exported as a FILE will have as a PREFIX the name of the file from which it comes. For batch processing of multiple PSD FILES.