Notes from the field on ColdFusion (or related) technical issues.

Wednesday, January 21, 2009

Automatically Fix Case Sensitivity Issues

When you're converting from Windows, with a case-insensitive file system, to just about any other operating system, you'll likely run into file naming issues.

If you have a file named MyInclude.cfm, and you try to use it in ColdFusion as <cfinclude template="myInclude.cfm" /> (note the lowercase "m"), this will work fine in Windows, but then fail on the new OS.

I've written a small template to automagically repair most of these problems. and you can download it here:

To plagarize mercilessly from its comments:


Fix file and directory name references in files, for transitioning from Windows (with case
insensitive filenames) to another OS (eg Linux) with case sensitive file names.

NOTE: If you have two different files (perhaps in different directories) with the same name,
but different case, this will not work as well as hoped. (All references will get set to
one or the other case.)


Place _referenceFixer.cfm in a document directory and load.
Template will start from its current directory and proceed to find all file and directory
names in that directory and its subdirectories.

If "updateFiles" is set to True, the files will be rewritten and references fixed.

"fileExtensions" should be set to list the files whose references should be checked
and (if updateFiles is true) fixed, eg. ".cfm,.html".

Templates beginning with an underscore character ("_") will be skipped.

Do NOT leave this on production servers..!

1 comment:

  1. I was facing exactly this problem! You saved me a TON of editing. Thanks!!!