Improve file detection / conversion during spec update

Agreed, this is really hard to follow.