I have a Windows Server 2008 R2 domain and shared folder on the same server accessed by everyone and the user put some stuff in this folder.

I'm struggling with filename length and a way for restricting the users storing and creating files with too long filenames.

If someone have info for a way restricting users in the domain writing longer filenames will be highly appreciated.

Just to clarify the required limitation for filenames is 40 characters for example, now they could put the maximum for example 248 characters.

  • Define longer file names. – joeqwerty Jul 16 '14 at 14:45
  • Define longer file names 2 characters is longer than 1 character. Is 2 characters a longer file name? – joeqwerty Jul 16 '14 at 14:50
  • For example the restriction could be 40 characters no more instead of leaving the users to put 258 characters this is long filename. – networkpro Jul 16 '14 at 14:57
  • So you want to restrict them to creating files with names no longer than 40 characters? – joeqwerty Jul 16 '14 at 14:58
  • Yes 40 chars and no more that's it. Sorry I couldn't catch from the first time your first question. – networkpro Jul 16 '14 at 15:01

The 248 chars limitation is set in the file system level.
The only possibility is if you use some custom file system or a program that use a hook to control every file creation (which would probably use your CPU too much).

Another option that might work is to create a network share with a name 208 chars long - that would simply prevent the users from creating a longer file name.


I thought maybe you could do this with File Group Definitions in File Screening Management functionality of File Server Resource Manager but it appears that the File Group Definitions do not support regular expressions.

In Windows Server 2012 R2 there is expanded functionality to File Server Resource Manager to incorporate regular expressions in Automatic Classifications which might help you identify "long file names" reactivity.

Since you are on Server 2008 R2 the only other thing I can think of is some PowerShell hackery:

$Files = Get-ChildItem | ? { !$_.PSIsContainer }

ForEach ($File in $Files) { 

    if ( $($File.Name).Length -gt 40 ) {

        # You may want to be nicer to your users than this...
        Remove-Item $File.Name -WhatIf



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.