https://pastebin.com/XBnxzFNt
I have a .jsx script that is supposed to perform the following tasks for all file pairs in the directory:
1. Load the displacement map, e.g. a_disp.dds
2. Load colorDoc - color source (not diffuse/albedo), e.g. c.png
3. Do a “Color match” on the map from step 1, using the map from step 2 as the source.
4. Open the normal map, e.g. a_n.dds.
5. Copy the displacement map to the Alpha channel of the normal map.
6. Save the normal map with the name taken from the displacement map and the suffix _nh, e.g. a_nh.dds.
7. Close the remaining maps without saving.
Why is this script unstable and does whatever it wants?
Sometimes it does everything correctly, sometimes it only creates one file and crashes Photoshop, sometimes the Alpha channels are saved as black in all files (and sometimes only in some), and sometimes it just crashes Photoshop?
https://pastebin.com/XBnxzFNt