Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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).

share|improve this answer
    
For some reason simply @FileLeafRef just didn't work for me but this does ddwrt:GetFileExtension(string(@FileLeafRef )) Thanks! SPArchaeologist! –  Tudor Sep 18 '12 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. –  SPArchaeologist Sep 19 '12 at 9:59
    
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 Sep 19 '12 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 ^_^' –  SPArchaeologist Sep 20 '12 at 7:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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