Link to home
Start Free TrialLog in
Avatar of LightWire
LightWire

asked on

How to find or search for invalid characters for OneDrive upload

Looking how to find or search for the following invalid characters in all the shared folders to prepare to upload to OneDrive.  

The characters are:

\
/
:
*
?



|
#
%
Avatar of arnold
arnold
Flag of United States of America image

What are you using to upload? a pattern match in your application to validate the file name .......
Avatar of LightWire
LightWire

ASKER

I need to verify my data structure before I proceed in the upload.  Is there a script I can use to produce an list of the output so it can be modified?
Yes.

Depending on what it is you are using, you have to look at the naming convention you use and make sure it matches the requirements .
I understand, but this is a customer's structure and they have over 100k + files/folders and I would like to search via a script instead of one at a time.
What scripting language are you using? powershell, vbscript, perl, batch, etc.
Each one has their own methods to traverse directories, and looking at filenames and then performing a pattern match to see whether they meet the requirements or have invalid characters.
 
You need to provide what options are available to you with which you are familiar at which point ....... it would be simpler to guide you along to the solution.
I'm not a script writer per say but can modify one when needed.  I am familiar with PS, VBS and batch
Here is an example of listing files in directories and sub folders.
vbscript example and powershell example.

http://blogs.technet.com/b/heyscriptingguy/archive/2014/02/03/list-files-in-folders-and-subfolders-with-powershell.aspx

Are you looking for someone to write you the script?
or are you looking for suggestions/correction of your own script that is doing somethings but not all that you need?

What is the end goal of your script processing?
Are you looking to rename the filenames to meet the parameters of onedrive?

An example of a powershell script that will replace "inavalid" characters with an alternate valid one.
http://pshscripts.blogspot.com/2013/11/fix-filenameps1.html

The general premise is
list the current directory, if it is a file, check the naming convention.
If it is a directory, check the naming convention and then look further within.

You can do it iteratively.
Function to look through the directory that is being passed to it. and if it hits a directory calls the same function with the new path as the argument
find_files (c:\)
find_files(c:\somedirectory)
etc.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I seen a ps script like this one as well which I will run tomorrow. Thx
I've requested that this question be closed as follows:

Accepted answer: 0 points for lightwireinc's comment #a40686146

for the following reason:

Script runs good and helped find what I needed
I think you forgot to choose the comment with the script that helped you resolve the issue at hand. Your own comment acknowledges the assistance and is not a solution.
This script was very helpful and was what I was trying to use from another find but did not work properly.  I did modify the search by adding the following characters


            $illegalChars = '[&{}~#%/:*?<>|]'

#These characters may be used on the file system but not SharePoint
                if ($_.Value -match "&") { $newFileName = ($newFileName -replace "&", "and") }
                if ($_.Value -match "{") { $newFileName = ($newFileName -replace "{", "(") }
                if ($_.Value -match "}") { $newFileName = ($newFileName -replace "}", ")") }
                if ($_.Value -match "~") { $newFileName = ($newFileName -replace "~", "-") }
                if ($_.Value -match "#") { $newFileName = ($newFileName -replace "#", "") }
                if ($_.Value -match "%") { $newFileName = ($newFileName -replace "%", "") }
            if ($_.Value -match "/") { $newFileName = ($newFileName -replace "/", "") }
            if ($_.Value -match ":") { $newFileName = ($newFileName -replace ":", "") }
            if ($_.Value -match "'*") { $newFileName = ($newFileName -replace "'*", "") }
            if ($_.Value -match "'?") { $newFileName = ($newFileName -replace "'?", "") }
              if ($_.Value -match "<") { $newFileName = ($newFileName -replace "<", "") }
            if ($_.Value -match ">") { $newFileName = ($newFileName -replace ">", "") }
            if ($_.Value -match "|") { $newFileName = ($newFileName -replace "|", "") }
            }
Sorry arnold, I chose the wrong thing.
The Long path tool is the very best program for error, unlock solution.and it is very useful tool.
“Long Path Tool” is very helpful for this error ! best solution for your problem.