Yes there is code to assign categories to media.
I will try your suggestion. Thank you for your help.
I uploaded the media through the dashboard. Then assigned the categories to them. This would mean they are not necessary part of any post.
I did use the slug not the name, but no joy there.
and yes I was planning on using the array form. I just wanted to get something working to make sure I barking up the right tree.