23

I am working on SharePoint Admin and Development part. One of our customer is using SharePoint 2013\2016. User is getting Special character issue while uploading file in SharePoint 2013\2016. We are searching for characters those are not allowed in SharePoint 2013\2016 files\folders. Found for SharePoint 2010 but not found for SharePoint 2013\2016.

Can you please help me to list down the special characters not allowed in SharePoint 2013\2016 files\folders?

Thanks.

18
~, #, %, & , *, {, }, \, :, <, >, ?, /, |, “

above special character is not allowed for files/folder.. you need to replace these characters for create folder or files..

  • 3
    is ! allowed ? – Arsalan Adam Khatri Jul 8 '14 at 7:47
  • is it related to SharePoint 2013? I know for SharePoint 2010. – MAK Jul 8 '14 at 8:41
  • 1
    Yes Arsalan, ! is allowed.. – Hitesh Chandegara Jul 8 '14 at 10:05
  • also it for both SP 2013 and 2010 – Hitesh Chandegara Jul 8 '14 at 10:05
34

You cannot use the following characters in file/folder name:

Tilde (~)
Number sign (#)
Percent (%)
Ampersand (&)
Asterisk (*)
Braces ({ })
Backslash (\\)
Colon (:)
Angle brackets (< >)
Question mark (?)
Slash (/)
Plus sign (+)
Pipe (|)
Quotation mark (")

There are also restrictions about the positition of a character in a file/foldername:

  • You cannot use the period character consecutively in the middle of a file/folder name.
  • You cannot use the period character at the end of a file/foldername.
  • You cannot start a file/foldername with a period character.
  • If you use an underscore character (_) at the beginning of a file/foldername, the file/folder will be a hidden file/folder.

In addition, file names and folder names may not end with any of strings:

.files
_files
-Dateien
_fichiers
_bestanden
_file
_archivos
-filer
_tiedostot
_pliki
_soubory
_elemei
_ficheiros
_arquivos
_dosyalar
_datoteke
_fitxers
_failid
_fails
_bylos
_fajlovi
_fitxategiak

Source: http://support.microsoft.com/kb/905231/en-us

  • Is it related to SharePoint 2013? I know for SharePoint 2010. The link given is Applies to: Microsoft Windows SharePoint Services 3.0; Microsoft Windows SharePoint Services 2.0; Microsoft Office SharePoint Server 2007; Microsoft Office SharePoint Portal Server 2003; Microsoft SharePoint Foundation 2010; Microsoft SharePoint Server 2010; – MAK Jul 8 '14 at 8:44
  • Yes, it is correct for SharePoint 2013 too. – Nikitin Nikolay Jul 8 '14 at 11:20
  • Can you edit your answer with "Backslash (\)"? Because of formatting it seems like it says "Backslash ()", I cannot edit it because of the minimum required characters. – Roberto Alarcon Jan 21 '15 at 1:00
  • Ya but in my case it is not allowing ; character also while downloading the file it removes ; semicolon character from the name of the file. – Niranjan Kulkarni Jun 24 '15 at 8:20
7

Not to resurrect an old thread but I thought I would add my regex. One issue from KB905231 it is not clear if the prohibited file suffixes (i.e. .files or _files, etc.) are including or excluding the file extension. I assumed including so foo.doc.files would not match but foo.files.doc would.

^(?![\._]|.*(?:\.|\.files|_files|-Dateien|_fichiers|_bestanden|_file|_archivos|-filer|_tiedostot|_pliki|_soubory|_elemei|_ficheiros|_arquivos|_dosyalar|_datoteke|_fitxers|_failid|_fails|_bylos|_fajlovi|_fitxategiak)$)[^!#%&*{}\:<>?\/|"]+$

Edit (1/26/17): It did not prevent tilde or double period in the middle. Here is a new one with some unit tests at https://regex101.com/r/XWYV2r/2

This is only lightly tested. YMMV.

(?!.+\.\..+)^(?![\._]|.*(?:\.|\.files|_files|-Dateien|_fichiers|_bestanden|_file|_archivos|-filer|_tiedostot|_pliki|_soubory|_elemei|_ficheiros|_arquivos|_dosyalar|_datoteke|_fitxers|_failid|_fails|_bylos|_fajlovi|_fitxategiak)$)[^~#%&*{}\\:<>?\/|"]+$
  • This was very useful for me however does not catch the "ending period" exception or the "consecutive period" exception – SP Combatant Jan 26 '17 at 15:18
  • 1
    Try the new one. I improved it a bit – gamelover42 Jan 27 '17 at 4:38
  • @gamelove42 - thanks! I forgot tilde in my answer below - updated – SP Combatant Jan 27 '17 at 16:35
1

Instead, this regex "matches" on any file name using restricted characters. Including "beginning or ending period" and "consecutive periods"

'^[\._]|[!#%&*{}\:<>?\/|"~]|\.{2}|\.$|(?:\.files)$'

Below is the context in which it's used, this Powershell script recursively outputs all filenames located in $DirectoryPath to a .CSV and includes a size column (since SharePoint has a max file size of 50mb) and displays the restricted characters used by the file name.

Get-ChildItem `
        -Path $DirectoryPath `
        -Recurse `
    | where { ! $_.PSIsContainer } `
    | Sort-Object name `
    | Select-Object `
        @{ l='Character'; e={ [regex]::Matches($_.name, '^[\._]|[!#%&*{}\:<>?\/|`"~]|\.{2}|\.$|(?:\.files)$') } } `
        , @{ l='mbSize'; e={ $_.length/1MB } } `
        , Directory, BaseName, extension 
    | Export-Csv `
        -Path 'c:\Temp\files.csv' `
        -Encoding ascii

The script does not list folders, only file names

0

If someone has to validate these characters with a regex (js or C#), the following regex will work:

 /^([^\~|\#|\%|\&|\*|\{|\}|\\|\:|\<|\>|\?|\/|\||\"])+$/

That will be something like: "Match anything except for the following characters any number of times"

(I am not very good at regexs so, please correct me if I'm wrong)

-2

"~", "#", "%", "&", "*", "{", "}", "\", ":", "<", ">", "?", "/", "+", "|", ".." Aboove is the list of special characters which are not eligible for naming a sharepoint file. it gives and error if user try to cerate a file with these characters is misleading sometimes. "the file name you specified is not valid or too long."

".." is also not valid special characters for a file name in sharepoint. People ignore it most of the time.

  • You are simply repeating what others have answered. – Johan Brännmar Aug 15 '18 at 13:17
  • the list mentioned by others is not complete , double dots ".." is also not valid special characters for a file name in sharepoint. People ignore it most of the time. – Virendra Chaudhary Aug 15 '18 at 13:56
  • Yes they do. "You cannot use the period character consecutively in the middle of a file/folder name." sharepoint.stackexchange.com/a/105997/42862 Also what do you have that supports your answer that people ignore most of the time. – Johan Brännmar Aug 15 '18 at 13:59
  • because most of the time during testing single dot is considered which is valid case but fogot to test double dots which is also a valid test scenerio. – Virendra Chaudhary Aug 15 '18 at 14:08
  • There really isn't any point for resurrecting this old of a thread. Your argument that .. isn't mentioned is false, as Brannmar said. Nikitin Nikolay says it, gamelover42's second regex supports it, and SP Combatant's regex supports it. Please read the other comments before repeating old news. Having too many answers in a thread can confuse people trying to find a simple answer. – KGlasier Aug 15 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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