• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Fastest way to search a directory for file names with specific characters

We just started using Office365 and, unbeknownst to us, you can't upload files containing certain characters to Sharepoint Online. The names of the files we are trying to upload cannot contain these characters:   " # % & * : < > ? \ / { | } ~
We have all of the folders that we plan on uploading in a single directory called "to be uploaded to sharepoint"
Is there any way to search through this directory and all of the subfolders in that directory for files with those invalid characters in their names?
I tried using a command like this,

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

that I found on another website, but it just returns a list of all of the files and folders in that directory, regardless of whether or not their name contains an invalid character.

Any advice would be greatly appreciated.
  • 2
1 Solution
Some of those characters aren't valid for NTFS, so it does no good to search for them.  Here's a line of PowerShell code that should work for you.
Get-ChildItem "c:\tobeuploadedtosharepoint" -recurse | Where { $_.name -match "[#%&{}~]" } | Select FullName

Open in new window

BroadsoundAuthor Commented:
Thanks for the response,
I found a free application online called Agent Ransack .

It does exactly what I need very efficiently.
Put the files into a Folder, do not use any of the forbidden characters as the Folder's Name.  Upload.
BroadsoundAuthor Commented:
Found an application online that does exactly what I need
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now