Monday, October 23, 2017

#1 2008-03-19 05:47:39 pm

Mark Munro
Member
Registered: 2008-01-16
Posts: 175
Website

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.


Applescript:



--    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

Offline

 

#2 2008-04-02 05:58:57 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4412

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

Applescript:

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:

Applescript:

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:

Applescript:

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.


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)