21 Jan

Show File Extension in Sharepoint Document Library

I was recently tasked with changing the view in our TFS Project Portal’s document library to show the file extension so you knew whether you were opening a PDF, Word Document, PowerPoint or something else for which you might not have the software installed.  There is an easy way and a hard way, and the guidance I received from a few Google searches skipped a few steps on the hard way.

Easy Way

  1. Open the Document Library
  2. Click on the Library Tools -> Library tab at the top
  3. Scroll to the bottom and click the view you wish to change
  4. Check “Name used in forms” column

This adds a new column with the full file name and extension, but it’s not clickable to view the document, so you end up with two columns for document name, the name and the name with extension.  This is why I ended up going down the hard way.

Hard Way

  1. Open the site in SharePoint Designer
  2. Click Lists and Libraries and open the Document Library you want to modify
  3. Open the View you want to modify
  4. Right click on the first row in the Name column and select Insert Formula
  5. In the Edit XPath expression box enter something that is easily searchable ie. xxxxxxxx
  6. Click OK
  7. Switch to the Code View
  8. Search for your xxxxxxx and delete the element it created
  9. Right above or below that should be an element like so <xsl:value-of select=”$thisNode/@FileLeafRef.Name” />
  10. Replace that with <xsl:value-of select=”$thisNode/@FileLeafRef.Name” /><xsl:if test=”$thisNode/@FileLeafRef.Suffix!=””>.<xsl:value-of select=”$thisNode/@FileLeafRef.Suffix” /></xsl:if>
  11. Save, exit and you’re done

The examples I found online left out steps 4-8, and until I did those the <xsl:value-of select=”$thisNode/@FileLeafRef.Name” /> element didn’t exist.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>