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.
arnold
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.
LightWire
ASKER
I'm not a script writer per say but can modify one when needed. I am familiar with PS, VBS and batch
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?
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.
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.
LightWire
ASKER
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 "|", "") }
}