Drupalers,

I have a large number of files (in the thousands) which I need to add to Drupal. Obviously, I'm not going to do this by hand, so I am writing a script to do this. I have figured out how to create nodes for each document (node_save), but now need to figure out how to attach the files to the node. I looked over upload.module, but didn't understand it well enough to guess which function I needed to call.

Can anyone offer some ideas how I can do this?

Thanks!!!