locked
Display File Extension throught Site Collection in SharePoint 2013 RRS feed

  • Question

  • Is there any way we can implement File type extension column all the document library at once in SharePoint 2013?

    I was able to apply to individual document library at given time as we are having 100s of these is there a way to implement on all at once.

    Thanks.

    FYI,

    I modified the view in designer and added <FieldRef Name="LinkFilename"/>  tag under <ViewFields> tag. Used this to apply on individual site collection.  

    Thanks.

    Tuesday, August 2, 2016 5:20 PM

Answers

  • Hi adi225,

    From your description, you want to display File Extension in all document libraries, you can add "Name (for use in forms)" column in all document libraries by using PowerShell:

    Add-PSSnapin microsoft.sharepoint.powershell
    
    $site = Get-SPSite http://sp/sites/team1
    #Get all web sites in the site collections 
    $webs = $site.AllWebs 
    foreach($web in $webs) 
    { 
        #loopthrouh the lists and libraries in the site 
        for ($i = 0; $i -lt $web.Lists.Count; $i++) 
        { 
           $list = $web.Lists[$i];
           echo $list.Title
    		#Check for only document libraries         
            
     		    if($list.BaseTemplate -eq "DocumentLibrary") 
     		    { 
     			   
                    $view =$list.DefaultView;
                    #$view.ViewFields.Delete("FileLeafRef");
                    $view.ViewFields.Add("FileLeafRef");
                    $view.Update();
               
     		    }
            
     	} 
     } 
    
    

    Note: change the site collection  to your site collection.

    Add field to SPList default view:

    http://stackoverflow.com/questions/7160373/add-field-to-splist-default-view

    Get all document libraries in a site collection:

    http://www.sharepoint-journey.com/get-all-document-libraries-in-a-site-collection.html

    Best Regards,

    Lisa Chen


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.





    Wednesday, August 3, 2016 8:32 AM

All replies

  • Hi,

    Use powershell to iterate through the libraries present in your site, and then enable the field you want


    Thanks, https://www.fiverr.com/rashu268 Rahul Rashu

    Tuesday, August 2, 2016 6:34 PM
  • If you can give me steps to execute. It will be Helpful.  

    Can you Please let me know the command which I have to run. Thanks

    Tuesday, August 2, 2016 9:28 PM
  • Hi adi225,

    From your description, you want to display File Extension in all document libraries, you can add "Name (for use in forms)" column in all document libraries by using PowerShell:

    Add-PSSnapin microsoft.sharepoint.powershell
    
    $site = Get-SPSite http://sp/sites/team1
    #Get all web sites in the site collections 
    $webs = $site.AllWebs 
    foreach($web in $webs) 
    { 
        #loopthrouh the lists and libraries in the site 
        for ($i = 0; $i -lt $web.Lists.Count; $i++) 
        { 
           $list = $web.Lists[$i];
           echo $list.Title
    		#Check for only document libraries         
            
     		    if($list.BaseTemplate -eq "DocumentLibrary") 
     		    { 
     			   
                    $view =$list.DefaultView;
                    #$view.ViewFields.Delete("FileLeafRef");
                    $view.ViewFields.Add("FileLeafRef");
                    $view.Update();
               
     		    }
            
     	} 
     } 
    
    

    Note: change the site collection  to your site collection.

    Add field to SPList default view:

    http://stackoverflow.com/questions/7160373/add-field-to-splist-default-view

    Get all document libraries in a site collection:

    http://www.sharepoint-journey.com/get-all-document-libraries-in-a-site-collection.html

    Best Regards,

    Lisa Chen


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.





    Wednesday, August 3, 2016 8:32 AM
  • Thanks, Lisa.
    Wednesday, August 3, 2016 6:37 PM