SharePoint offers a little-known but incredibly useful feature allowing for bulk adds, updates, and deletes of list items via the SPWeb.ProcessBatchData method. The usage is a bit complex because you need to pass CAML markup to the method to perform the operation on multiple list items. This CAML must contain the list item ID, list GUID, and relevant column names and values in an XML collection. There are numerous examples throughout the web showing how to write this CAML for manipulating list items in regular lists, but there is a quirk to manipulating document properties in a document library.
Upon successfully passing correct CAML to the ProcessBatchData method, the return value will be more CAML denoting which items were modified along with a code denoting the success of the operation on that item. A code of zero means success.
To my great frustration I was passing well-formed CAML to ProcessBatchData and receiving confirmation via the return object that my updates to document properties in a document library had been successful. However upon viewing the document library, the properties had not been updated.
To resolve this, I had to add an extra element to each Method tag. (A Method tag corresponds to an operation on a list item.) The element format is as follows.
When formatting this string, pass the server-relative URL of the file associated with that list item, accessible via SPListItem.File.ServerRelativeUrl or if the item is a folder then SPListItem.Folder.ServerRelativeUrl. After passing in this additional element for each method, your operations should execute correctly on documents in document libraries.
Learn more about DMC's SharePoint consulting services.