Home > Libraries, SharePoint Designer 2010, SharePoint Server 2010 > How To Rename All Files In A SharePoint 2010 Document Library

How To Rename All Files In A SharePoint 2010 Document Library

In the previous post, I talked about an alternative way to looping in SharePoint Designer 2010. Let’s say you have uploaded a few hundred documents into a document library and then you did not like the file names – for example, most of them have a space you want to get rid of, or even worse: a comma.
If you can access a network share with required security and other business rules, you may put the library in Windows Explorer view, map to a network share and use a standard file re-naming utility (or even run a command line or Powershell). Otherwise, you can use code and batch process the library. But if you only have access (and rights) to SharePoint Designer 2010 in addition of your SharePoint site, you can still do it. Our example library has documents (ex. CVs) named something like “smith,john.docx” and you want to rename it as “smith_john.docx”.
First, create a temporary text column (TempName) and a calculated text column (NewName). NewName replaces commas from TempName with underscores. Here’s the formula (one comma – the first one):
=IF(ISNUMBER(FIND(“,”,TempName)),REPLACE(TempName,FIND(“,”,TempName),1,”_”),TempName)
Why not just use the Name field? Well, you do not have access to it from SharePoint, but SharePoint Designer 2010 can get it. SO, we create a workflow against our library that: 1. Update the current item by setting TempName to Name (for use in forms) – which is the name without extension. 2.Pause for a while (1 minute) – to make sure the item has updated. 3. Set the Name field to the NewName (which should have been calculated since TempName has changed).
In the WF settings, check the Start WF when item changes. Check for errors, save and publish. Use the previous trick to trigger all item change and your workflow will do its work. When done, remove the workflow and also remove the three fields (TempName, NewName and the dummy column you added to for auto-fill). You should not do this during peak time and could do it several times if you want to get rid of more than one character per name.

Categories: Libraries, SharePoint Designer 2010, SharePoint Server 2010 Tags: Rename files
  1. Mark
    May 12th, 2011 at 07:08 | #1

    I would like to share with you a 6 day certification boot camps which can help you to obtain SharePoint 2010 certifications for both administrator and developers.

    If you want to know more you can visit @ http://www.campsharepoint.com/ and learn more about the upcoming conferences.

  1. No trackbacks yet.
Using A Workflow To Protect A Blog Against Bad Words An Alternative To Loop Action In SharePoint Designer 2010 Workflow