2

I had to make a few changes to an old document library's template (an InfoPath form), which somehow managed to invalidate the old documents. I have something around 40,000 documents in this library, and yes, I need all of them.

So. I need to update all the documents to match the new template structure, which can be done by opening then closing the form. However, opening and closing 40,000 documents would be time consuming, expensive, and laborious.

Is there a better way to do this?

5
  • do you want checkin and checkout of all files?
    – Waqas Sarwar MVP
    Commented Jul 7, 2016 at 21:54
  • @WaqasSarwarMCSE That entirely depends, will that act the same way as opening then closing the files? If so, then yes, absolutely! Commented Jul 7, 2016 at 22:07
  • what you want to update? some metadata like columns, right?
    – Waqas Sarwar MVP
    Commented Jul 7, 2016 at 22:12
  • @WaqasSarwarMCSE Yes, I've added some columns, and now none of the files show up my views because most of the columns appear to be empty, even though they are present in the XML. Opening and closing the form will update the file, and my views will see it again, but I cannot do that 40,000 times in a row. Sorry if this is basic; I'm a programmer, not an InfoPath/Sharepoint guy. Commented Jul 7, 2016 at 22:15
  • I should note that I found out a way to get around having to do this: instead of making changes to the form template for the library in Advanced Settings, enable Content Types on the library, and start publishing new versions as new content types instead of overwriting the existing template every time. That way you keep old versions of the form when you update, so files made with that version still show up as they did, and the files don't de-link requiring this solution. Commented Apr 18, 2019 at 21:38

2 Answers 2

2

Turns out, there is a button one can push to update all the documents to match a new template, no scripting necessary.

  1. Go to the Library's settings page
  2. Under "Permissions and Management" use the "Relink documents to this Library" link, which brings you to what looks like a view.
  3. In the Documents ribbon, use "Relink All", or select the ones you want to fix and use "Relink"; depending on your use case.

This will go through every file and update their meta data so they fit under the new template structure. Took about 4 hours, but hey, it worked, and I didn't have to do everything manually.

Here's a link to an MSDN blog post which might help the next person with my particular problem, even if it's a little lingo-heavy. It talks about this issue, but also starts talking about moving between libraries, and gets a little confusing about it.

2
  • Side note: I found this while trying to figure out how to copy some of my broken documents so I could test a Powershell script based on Waqas Sarwar's answer. Commented Jul 8, 2016 at 19:06
  • Saved my Day... :) Thanks Commented Apr 16, 2019 at 7:13
0

In this case, what you have to do is use PowerShell script which will do this

  • Check out the documents
  • update the columns with required data( i am assuming the same data for all docs)
  • check in.

here is small script but it will work for one document, you have to loop it.

$web = get-spweb http://myweb
$list = $web.Lists["documents"] -as [Microsoft.SharePoint.SPDocumentLibrary]
$item = $list.items[0]
$url = [String]::Format("{0}/{1}",$web.Url, $item.File.Url)
$file = $web.GetFile($url)
$file.CheckOut()
# Do Stuff
$file.CheckIn("Add your comment here!")

from here

another example is here How to update document meta data using powershell

1
  • PowerShell really isn't my thing, but I'll try it. I've been meaning to get around to learning it for a while now; suppose that time is now. Commented Jul 8, 2016 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.