Hi folks, I am trying to adapt some AppleScripts for setting the Finder comments of a whole bunch of files at once. I am running into a problem when I try to deal with a file with a very long OS X name.
I should say that my computer has both OS 9.2.2 and OS X 10.2.8 installed. The problem comes when I try to run the script when I am booted up under OS 9 (OS X is not active).
here’s the subroutine
on setComments(fileList, source_folder)
global newComment -- already set by caller
global doOverWrite -- already set by caller
repeat with i from 1 to number of items in the fileList
set thisItem to item i of the fileList
set thisItem to (source_folder & thisItem) as alias
tell application "Finder" to set fileInfo to info for thisItem
set is_folder to folder of the fileInfo is true
tell application "Finder" to set fileComment to comment of thisItem
if (doOverWrite is true) or (fileComment is "") then
tell application "Finder" to set the comment of thisItem to the newComment
end if
if is_folder then
tell application "Finder" to set newList to list folder thisItem
set thisItem to thisItem as string
my setComments(newList, thisItem)
end if
end repeat
end setComments
Well folks, this works fine as long as the file name is not really long…here’s an example of what happens when it “breaks”…
the actual file name & path in OS X is:
Xena:System:Library:ColorPickers:NSColorPickerCrayon.colorPicker:Resources:NSCrayonPickerBackgroundImage.tiff
the file name as shown in the OS 9 finder is:
NSCrayonPickerBackgrou#7AB.tiff
the result of listing the folder that contains the long-named file is:
{ …, …, …, “NSCrayonPickerBackgroundImage.tiff”, …, …}
so you see it uses the long OS X name here.
it fails at the statement
set thisItem to (source_folder & thisItem) as alias
with the error message
Bad name for file.
So…what can I do?
Thanks in advance!