If you do a search you will find a few methods including some standalone programs as well as an addin or plugin for Calibre.
I've also used the link below where you place your books in subfolders on the kindle and grab a directory/folder listing which the site returns as the appropriate collections.json file.
http://www.accwebworks.com/kindle.aspx