Application icon

Filename Lengths

Macs support a wide variety of file systems. Different file systems have varying maximum filename lengths, case insensitivity and other properties.

The base Mac filesystem, HFS, has a maximum filename length of 255. However, the filenames are stored as decomposed UTF16 characters. When 16 bit Unicode characters are decomposed, it is possible that a single accented character occupies more than one character position. If you are attempting to pre-check the length of a file system path component this eventual decomposition can make it difficult as the length of the component may not be the length when decomposed.

In order to enable better testing, the following special options are available.

When renaming, the ❨IfLength❩ token can take negative values. When a value is negative the length test is performed on the constructed rename value after decomposing. Similarly the ❨Truncate❩ token, when negative, truncates the decomposed representation. Using these values you can safely truncate names when renaming.

Example:

❨IfLength❩
    -250❨Truncate❩-250❨Break❩
❨endIf❩
❨IfDup❩
        ❨Truncate❩-245❨Break❩·(❨Dup #❩)

The above example tests if the accumulated rename pattern is greater than 250 decomposed characters. This leaves room for a filename extension of five characters. (.aiff is the largest audio file extension supported by Yate). If the filename is a duplicate, five addition characters are removed to leave room for the duplicate pattern.

Similar to the handling of the above rename tokens, the Truncate Variable action statement can specify a negative length. If negative, the length test is performed on the decomposed contents of the supplied variable. If truncation occurs, the decomposed contents are truncated. Note that when storing the result, the data is precomposed to make it easier to perform subsequent text base functions on the data.