Script begins before image fully loaded (I think)

I’m sure I’ve seen this somewhere on this site before but no combination of search keys I’ve tried is turning it up so…

I have a script to watch a hot folder via an idle handler that opens files in Photoshop CS2.

The problem is that occasionally when I get larger files, the bottom of the file is corrupted. (But not always - drop the same file again and it’s fine.) I suppose this is because it’s loading before the entire file has been copied to the hot folder.

My obvious question - how can I determine that the entire file is there before opening it? This will be a folder on a Helios-mounted Unix server volume, so I’m not sure what would be effective here, such as Objective-C methods or Unix “fuser” calls or ??? Or do Photoshop Actions offer anything that AppleScript doesn’t that would help here? What does the AppleScript Intelligensia do to handle this?

Thanks very much for any suggestions.

  • Dan

fstat
I’ve been meaning to look at this myself for work…

Have a look at this osxhints thread

EDIT** seems right at the bottom of the thread, they run into problems with fstat not working as expected…

But one Poster mentions rechecking file size as an option…

Ah, now there is a link to a hint on the thread which talks about a "bzy " file type see the quote below. from this Thread

Thanks a lot Mark. I’ll look at fstat, but now that you mention it the file size check is probably the most reliable - I’d done that in the distant past somewhere else and forgot all about it. Certainly one of those will work :slight_smile:

Much obliged!

  • Dan

Edit: Whoa, I posted this and then saw your second post. "bzy "? I never knew that…if that works then it’s definitely the way I’ll go, if only because of the coolness factor. Some things trump efficiency, and cool is one of them.

Thanks!

Yer does sound good.

I just copied a 1.4gb avi file from one folder to another.

ran

/Developer/Tools/GetFileInfo path/to/file/destination/nameOffile

and got :

type: “brok”
creator: “MACS”
attributes: avbstclinmedz
created: 08/28/2006 22:15:14
modified: 08/28/2006 22:15:18

Notice the “brok” maybe they changed it to broke, which Gives me some other ideas for other stuff.
Any way after it finished I got

type: “”
creator: “”
attributes: avbstclinmedz
created: 01/01/1904 00:00:00
modified: 06/25/2005 10:46:04

So so far it seems to work although I need to find some more large file types

Yeah, I’m seeing “brok” too.

I think this’ll work nicely - I’d be surprised if we encountered anything much bigger than 100MB but theoretically any size is susceptible, I guess. Nice…