'Script' might be a big word, but a command-line way to remove all the
files that are not used in Ardour(3). Is it safe to assume that all
files found in ../dead/ can be removed without deleting files that are
in use ?
You are expected to use Session > Cleanup > Empty Wastebasket
If you don't use that, then purging everything under the dead/ subdirectory is acceptable but not supported.
There is no way to to automate the behaviour of Session > Cleanup > Clean-up Unused Sources
(it involves quite a lot of knowledge about session structure, and potentially recursive parsing of XML).