Losing comments when transfering files

I’m very new at this scripting stuff but it’s very addicting and I’m wondering if it can solve some of my other chronic Mac OS X problems.

The longest standing problem I have is as follows:
I usually put important notes and/or info into the comments field of image files, usually created on photoshop. The notes that I enter in the Mac OS X comments field of the file info box doesn’t carry over to Mac OS 9, so I restart the computer in OS 9 and enter the same comments in the file’s OS 9 info box’s comments field.

Is there any way to use a script to fill in comments so that they’ll show up in both systems? If not, I can live with it.

The real problem comes when I copy the files either to my external backup hard drive or to DVD. I burn a DVD, or copy the files in Mac OsX, and the comments are gone on the copy when I open it in Mac OS 8.5 or 9. The guys at the Apple “Genius Bar” tell me that’s just the way it is. But I’m wondering if the comments can be saved when copying, via a script.

That’s problem #1

The other problem is that if I have to make a change to any file on photoshop, and then save the changes, the new updated version of the file loses the comments in comments field of the file info box. (The icon also jumps to somewhere else in the folder usually as well when it is saved after making the changes). A couple times the finder has crashed just as I’m saving the file with the interesting result that when the finder starts itself again, the file I just changed and saved has the comments left intact and remains in the same spot in the folder, although when I open the file in Photoshop to check, the changes I made to the image were saved. This has led me to believe that maybe this too is something a script could solve (i.e without having to crash the finder)

Does anyone have these same problems or, better yet, has anyone found solutions via scripting?

If so please post a reply.

I think you’re certainly out of luck on the first problem.

File comments are stored in the disk directory and maintained by the Finder. Consequently the only AppleScript access to the comments are via the Finder, and you can’t run both Mac OS X Finder and Mac OS 9.x Finder simultaneously.

About the only way it might work is to have some kind of intermediate file in which you store the comments using one script to copy the current comment into the file. When you boot into the other OS, another script reads the file and sets the file’s comments accordingly. It would take some work, though, to make sure you track the correct comments with the correct files and always copied the ‘right’ comment.

On the second issue, it’s easy enough to have a script relocate a file icon, but the difficulty is in determining which files should be in which location. If you only care about one folder, you could have a background script that records all icon positions when it starts and periodically scans the folder to reposition any icons that have moved.

The advantage of this approach is that you start the script when you want to ‘set’ the icon positions and you quit it when you’re done.

Save the following script as a stay-open script and you should find that any icons reset themselves every 10 seconds:

global folderitems, pos, theFolder

on run
	tell application "Finder"
		set theFolder to (choose folder)
		set {folderitems, pos} to {every item of theFolder, position of every item of theFolder}
	end tell
end run

on idle
	tell application "Finder"
		repeat with itemNo from 1 to (count folderitems)
			set curFile to item itemNo of folderitems
			set expectedPos to item itemNo of pos
			if position of curFile is not equal to expectedPos then
				set position of curFile to expectedPos
			end if
		end repeat
	end tell
	return 10
end idle

Camelot is right that the comments are stored by the Finder. It would be possible to create a script that indexed all the files in a particular folder and their comments and saved it to a flat text file and then have either Finder X or Finder 9 read that file and reassign all the comments…

As to the second part of the problem, below is a basic script that might help. Save the script as an app and then select a single file in the Finder that you are going to modify in Photoshop but instead of double-clicking the file to open it, drag & drop the file on the script app. The app will then store the file path, the comment, and the position, and open the file in Photoshop. Modify your image as much as you want in Photoshop, save, and close it. Now, run the script app by double-clicking it and it will move the file back to its original position, reset the comment, and reinitialize itself. A little bit of a pain but it works. This could also be easily modified to be run from the script menu. There is not much error checking in this script but it should work if used as described above.

Good luck,
Jon

There is one solution that just may work for you but it is command line based. osxutils 1.4 has a command line tool called setfcomment that allows you to set both OSX and OS9 comment data.

Once installed, you could incorporate that tool into a ‘do shell script’ applescript to set file comments
.
For example…


set myComment to "Thanks Sveinbjorn Thordarson.  Great work!"
set myFile to (the posix path of file "Mac HD:Path:To:Some:File")
set myShellString to "setfcomment -c " & myComment & " " & myFile as string
set shellReslt to do shell script  myShellString

I’ve had limited luck using this in the following circumstances however, perhaps someone smarter than I am will fill in the blanks as to why or how it would work better.

a)OS 9 created file, copied down from Novell server to Panther HD - set comment–> copy to back to server. Does not work.

b)OS 9 created file, residing on Novell server but copied from one directory to another by Panther. Tried various forms of copy–>MvMac, Ditto… No luck

*)OS 9 created file, residing on Novell server, put there by OS 9 station. Setting comment from Panther seems to have no effect, until I copy it down to an OS 9 box. Then, the comment appears.

I was just going to try it on setting comments directly on a file located on an OS 9 box.
UPDATE: This works immediately.

Best,