I struggled with this, and here is part of my decision. I have done this:
Create trace files in the tools with the script.js file of your choice and save it to disk.
Reads the UDID of all connected devices. Flip all connected devices and replace the UDID in the trace file with the UEID of the current current. In the same loop, the tools open.
for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'); do UDID=${line} file$x $(replace 345w67ww89ww0w98w762wewq33e2 with ${UDID}) open -a Instruments /PATH/TO/TRACE/file$x done
This solution will open several tool windows. You can go through them using appleScript to click the record button.
user728881 Oct 16 '12 at 7:05 2012-10-16 07:05
source share