I've been trying to solve this same problem actually.
The issue is that there doesn't seem to be a way to link the start/end of the trim paths to either a specific segment or vertex of the path.
There are some extendscript functions that will be useful:
https://ae-expressions.docsforadobe.dev ... 0-5-t-time
PointOnPath(%,t) will return (x,y) values given a specific % of the path length, but I haven't been able to figure out if there's a way to do the reverse: return a % given a known coordinate on the path.
So far my best idea is to use the 'method of exhaustion', which is to feed 'pointOnPath()' increments of something like 0.1%, and then compare the resultant values to a specified vertex point, and if the difference is within a certain error threshold, then use that % of the arc-length as the value for the start/end.