@humzariaz Here is the script that I use. Our use case is pretty specific, but every item on our site is a matrix item. This script is deployed with three parameters:
• A search ID for items you want to process. I created a “Process Item Images” custom field on the item record and just execute a simple search for those
• Your product images folder (mainly just for producing a final filename/URL)
• Your domain (again for producing a filename/URL)
Basically, it loads an item, loops through all the available matrix options and pulls the best image match for a matrix option and adds that all to a JSON string. Then, it loops through all the individual matrix children and tries to establish a single image for that child and adds another JSON string in a custom field. It also handles establish image captions, adds them to that JSON string and saves the text in the images caption field. You could manage captions manually in NetSuite, but I find it infinitely easier to manage locally using a bulk file renamer. It requires the file to be named very specifically, but those are noted on line 25. I’m sure you could edit to suit your needs.
It’s a map/reduce script because depending on how many images you have, it could consume a lot of governance. I’ve tried to schedule it to run, but it doesn’t really seem to work for whatever reason. I suppose it could be repurposed as a user event script, but it might slow down your item saves.
Hopefully this will save you some time or get you on the right track, but if you have any questions, feel free to reach out and I’ll do my best to answer