List Folder: 32 character folder names fail as strings [Updated]

This is a pesky problem in OS X 10.4. When using the “list folder” command with a folder (or path containing a folder) of 32 or more characters will result in a “Bad name for file” error. Even though the OS can handle longer names, this command can not. This problem exists for local folders as well as folder on an OS X server.

This problem appears to have been fixed as of OS 10.5.2 (even though my server is still using 10.4). It may or may not exist in 10.5.1.

[Updated] My original post erroneously showed an error return value for each attempt.



--	Note: If you try this code you will need to modify the volume name to your own server volume and create the folders.

--	Server Test
--------------------
list folder "Volume Name:abcdefghijklmnopqrstuvwxyzabcde:" -- 31 characters works
-- returns a list of items

list folder "Volume Name:abcdefghijklmnopqrstuvwxyzabcdef:" -- 32 characters fails (ERROR)
-- returns error "bad name for file"

list folder "Volume Name:abcdefghijklmnopqrstuvwxyzabcdef:" -- using an alias rather than a string works
-- returns a list of items

--	Local Test
--------------------
list folder "Macintosh HD:Users:mmunro:Desktop:abcdefghijklmnopqrstuvwxyzabcde:" -- 31 characters works
-- returns a list of items

list folder "Macintosh HD:Users:mmunro:Desktop:abcdefghijklmnopqrstuvwxyzabcdef:" -- 32 characters fails (ERROR)
-- returns error "bad name for file"

list folder "Macintosh HD:Users:mmunro:Desktop:abcdefghijklmnopqrstuvwxyzabcdef:" -- using an alias rather than a string works
-- returns a list of items


Hi, Mark.

I think you meant:

list folder alias "Macintosh HD:Users:mmunro:Desktop:abcdefghijklmnopqrstuvwxyzabcdef:" -- using an alias rather than a string works 
-- returns a list of items

A file reference also works:

list folder file "Macintosh HD:Users:mmunro:Desktop:abcdefghijklmnopqrstuvwxyzabcdef:" -- using a file reference rather than a string works 
-- returns a list of items

Aliases and file references are the standard ways of referring to files, folders, and volumes in AppleScript and are in fact what’s specified in the dictionary entries for list folder and other StandardAdditions commands. String ” or preferably Unicode text ” paths are usually coerced automatically these days, but occasionally produce strange results.