To convert a solid line into a series of smaller lines (not paths), use the method described at: https://community.adobe.com/t5/illustrator/transform-dashed-lines-into-separate-small-lines/td-p/2876098
I quote the answer given there:
Correct answer by tolyn_dayana
I know this is an old post. Just to share my method. I found the best
solution for this ...
I'm not sure you need a script. How about recording an action like this:
Convert your image to a Smart Object if it isn't already.
Add a Threshold Adjustment Layer and choose your wanted threshold.
Use Image > Trim and probably set Based On to Top Left Pixel Color to crop the image to the object.
Delete the adjustment layer.
To scale the image to the ...