Re: Is There No Limit?
Re: Is There No Limit?
- Subject: Re: Is There No Limit?
- From: Axel Luttgens <email@hidden>
- Date: Sun, 18 Mar 2012 16:03:43 +0100
Le 17 mars 2012 à 22:05, Luther Fuller a écrit :
> [...]
>
> Interesting. So I tried to manually add a very long comment to a folder. 604 characters. Nothing is truncated. The comment, even after a restart is 604 characters. (OS X 10.6.8)
>
> Surely there must be a limit to the length of a comment! But what is it?
> Is There No Limit?
Hello Luther,
I guess it depends on which Finder comment one is interested in...
on MakeString(C, L)
local s
set s to ""
repeat L times
set s to s & C
end repeat
end MakeString
tell application "Finder" to set comment of file "a.txt" of desktop to my MakeString("a", 10000)
tell application "Finder" to quit
delay 1
tell application "Finder" to run
delay 1
tell application "Finder" to get comment of file "a.txt" of desktop
--> ""
do shell script "/usr/bin/mdls -raw -name kMDItemFinderComment ~/Desktop/a.txt"
--> "aa...a"
In fact, we are facing the same problem as the one you raised the other day with the thread "Ghost Comments": when setting a comment thru the Finder's comment property, the filesystem's metadata store is updated, but the Finder relies on what it has put in the .DS_Store file.
And, as soon as the comment is long enough, the Finder doesn't seem to be able to correctly handle that invisible file anymore...
I never saw a written official upper bound for a Finder comment's length.
So, let's experiment with this quick code (better not to remove the delay statements, they avoid too much stress):
set cmtchar to "a"
set cmtstartlen to 1000
repeat with cmtlen from cmtstartlen to 20000
tell application "Finder" to set comment of file "a.txt" of desktop to my MakeString(cmtchar, cmtlen)
log {cmtlen}
delay 1
tell application "System Events" to (exists file ".DS_Store" of desktop folder)
if not result then
repeat with cmtlen from cmtlen - 1 to 1 by -1
tell application "Finder" to set comment of file "a.txt" of desktop to my MakeString(cmtchar, cmtlen)
log {cmtlen}
delay 1
tell application "System Events" to (exists file ".DS_Store" of desktop folder)
if result then
display dialog "Limit seems to be around " & cmtlen & " characters."
return
end if
end repeat
end if
end repeat
Here, with 10.7.3, the limit seems to be around 1005 characters.
Interestingly, the encoding in .DS_Store seems to be based on big endian UTF-16:
"a": 00 61 (latin small letter a)
"é": 00 65 03 01 (latin small letter e with combining acute accent)
"😄": d8 3d de 04 (smiling face with open mouth and smiling eyes)
As a result, the upper bound may be lower than 1005 characters; for example, trying with:
set cmtchar to "😄"
set cmtstartlen to 495
it appears that only around 500 characters are correctly handled in a Finder comment.
Would be interesting to test on other versions of the OS.
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden