3

I need to display the file extensions of the files in a Document library in a column. I have done a bunch of searching and came across solutions but they don't seem to be working for me.

This is what I have been trying to do:

  1. Open SPD and select my list
  2. Select the view that I want to add file extension column to
  3. Since I already created the column in the list setting on SP I just right-click in the first row of that column and 'Insert Formula', then enter this: @FileLeafRef.Suffix

Now nothing happens, my items don't show the extensions in the column in SPD and not in SP either.

Is there something I am doing wrong with this?

2 Answers 2

3

Using as a formula

string(@LinkFilename)

should return the full name (extension included) of the document (notice that using @FileLeafRef should return the same results). So, if you want to use @FileLeafRef you should strip the name from the returned string. This formula

ddwrt:GetFileExtension(string(@FileLeafRef ))

should give the expected result.

As an alternative, you should be able to use:

@File_x0020_Type

(see this link, provided with screenshot).

4
  • For some reason simply @FileLeafRef just didn't work for me but this does ddwrt:GetFileExtension(string(@FileLeafRef )) Thanks! SPArchaeologist!
    – Tudor
    Commented Sep 18, 2012 at 16:05
  • Glad you worked it out. You could also try and see if the linked tutorial (the one using @File_x0020_Type) works, but I guess there is no need for that if the other solution is working.
    – SPArcheon
    Commented Sep 19, 2012 at 9:59
  • 1
    I actually tried selecting FileType from the list which would give the @File_x0020_Type if I'm not mistaken...but that did not work, the only one I was able to get working was the GetFileExtension that you mentioned. However, the FileLeafRef worked fine on another server and environment, so I don't really have any idea why some of the options work and others don't
    – Tudor
    Commented Sep 19, 2012 at 15:32
  • It could be something related to the list content types, available fields or view definitions. Anyway, since you got it working, I would avoid to open that can of worms ^_^'
    – SPArcheon
    Commented Sep 20, 2012 at 7:21
0

The way I found that I like so far for "New/Modern" SharePoint is to modify the view to show Name (for use in forms)

  1. For myself, I select All Documents / Switch View Options Selecting "All Documents / Switch View Options"

  2. In the Columns section, put a check mark next to the column called Name (for use in forms) Selecting Name (for use in forms) in Edit View / Switch View Options

  3. Set the positioning of the column by selecting the appropriate positioning number.

  4. Click OK when done.

  5. Now the Document List will display the file extension for the uploaded files. The names now have the extensions included in the Name column

Source

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.