I need to remove these characters from the name of files in a folder. is regex the direction i need to go in?
\ / : * ? " < > | # { } % ~ &
Printable View
I need to remove these characters from the name of files in a folder. is regex the direction i need to go in?
\ / : * ? " < > | # { } % ~ &
it can be done with regex. i don't know how though.
heres how to do it with string manipulation
vb Code:
Dim filename As String = "invalidFilename\/:*?" & Chr(34) & "<>|#{}%~&.txt" Dim invalidChars() As String = {"\", "/", ":", "*", "?", Chr(34), "<", ">", "|", "#", "{", "}", "%", "~", "&"} For x As Integer = 0 To invalidChars.GetUpperBound(0) filename = filename.replace(invalidChars(x), "") Next filename = filename.Replace("in", "") MsgBox(filename)
You shouldn't even have to check for the first 9 characters you listed (\ / : * ? " < > |) as Windows won't allow filenames with those characters. The remaining characters are actually valid by Windows standards.
moving files to sharepoint...