I have a directory which contains sub folders which contain files with very diverse names from many different users so they are not named very consistently. I am moving this directory to a sharepoint site which does not allow certain characters as file names because the way it was designed they are reserved characters.

Invalid chars: " # % & * : < > ? \ / { | } ~

Referenced from: http://www.thesug.org/mossasaurus/Wiki%20Pages/SharePoint%20Invalid%20Characters.aspx

As you can see there are many chars which I would have to look for, I could tear through the many folders and hundreads of files hunting for each invalid char by eye, but is there a faster way can I go about searching the master folder which contains sub folders as well as their contents for each or every one of these chars so that only the folders and files with the bad chars show up?

Thank you for your time,


This ought to do the trick for you:

dir *#* *%* *^&* *{* *}* *~*  /s /b > bad_file_names.txt

This should pick up the files with bad characters and dump them in a neat little text file list. I omitted the characters that should already be invalid on Windows (I assume you're running Windows what with the SharePoint server).


Try something like Agent Ransack or WinGrep to search for the Regular Expression pattern:


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.