Aperture Script (Request?)

I’m not used to Applescript. But I have an idea what a lot of aperture user could help.
I know or assume this is not the right place to order something, but I didn’t find an appropriate place in this forum.
Is it easily possible to write a script which reads the foldername of a picture and places it into a “Keyword” ?
This would help to rebuild a structure within aperture or lightroom from the exported pictures using the sidecar-xml-files with the keyword-information. I don’t trust the aperture db and would like to rebuild a db from my backup export-files. This could also be handy if sombody wants to change to another application.
Did somebody already such a script ? Has anybody appetite to code it ?