Brian Dunning's FileMaker Custom Functions

MakeFileNameSafe

This function will clean up a string to be a safe file path on Mac, Windows or Linux

  Average rating: 5.0 (1 vote) Log in to vote

Jon Eisen   Jon Eisen - Show more from this author
Richard Carlton Consulting.com
https://rcconsulting.com

Share on Facebook Share on Twitter

  Sample input:
MakeFileNameSafe ( "Test/Demo" ; "_" )
  Sample output:
"Test_Demo"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

There are a handful of specific characters that are commonly used in strings that are unsafe for filenames across all major platforms. This will substitute them with a passed character.

It does not check that the replacement character is safe, nor do I guarantee that it covers all instances.

It also protects you from accidentally creating a file whose name will cause Windows Explorer to crash every time you try to open the file.

Note: this function removes all spaces which are allowed on Unix-based systems but not windows. Just comment that section out if you want spaces to be allowed.

If you find additional characters, let me know and I can add them.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: