It seems it was already on the wiki
http://www.creationkit.com/Complete_Example_Scripts#Script_a_container_that_only_accepts_certain_types_of_items
That code works just as well on a book shelf or any container with a valid formlist attached as it's property setting.
So Ultimately I really want to get a button that I can press and any 3d object that I'm not wearing gets sorted in to it's own container so that the player can actually get on with the adventuring instead of looking at inventory windows.
So I believe a button will be required attached to an invisible container bookshelf container (called InventorySorterContainer or ISC) with the script removed. when the player presses the button all the players inventory is moved to the ISC where another script will be used that checks the id against a set of formlists and moves it to the right container. All remaining items in the ISC is returned back the player.
So that's two scripts, any ideas
At least the ISC will contain something like this
Spoiler
Scriptname SidWeapIron extends ObjectReference
FormList Property SidWeapIronList Auto
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If akSourceContainer == Game.GetPlayer()
If !SidWeapIronList.HasForm(akBaseItem)
RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
Debug.notification("This Can Only Hold Iron Weapons")
EndIf
Endif
EndEvent