Created
January 5, 2017 14:44
-
-
Save dgibson666/dc2e5b583b4988b1b92935c4c6ca793f to your computer and use it in GitHub Desktop.
Create Valid Filename UDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CONVERT A STRING TO A VALID FILENAME | |
function CreateFileName(string){ | |
var str=Trim(string); | |
// replace invalid filename characters: /\:*?"<>| and whitespaces with underscores | |
str=ReReplace(str,"[*?\""]","","ALL"); | |
str=ReReplace(str,"\s","_","ALL"); | |
str=ReReplace(str,"[:<>|]","-","ALL"); | |
str=Replace(str,"\","_-_","ALL"); | |
str=Replace(str,"/","_-_","ALL"); | |
// leading period is also invalid for MACs | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment