From: Gary Wright Date: 2009-07-17T09:33:32+09:00 Subject: Re: making sure a file isn't being written/copied before moving On Jul 16, 2009, at 4:48 PM, Paul Archer wrote: > Tomorrow, Brian Candler wrote: > >> Paul Archer wrote: >>> Can someone suggest an easy (or at least reliable) way to make sure >>> that >>> any file I'm about to modify isn't being touched by another program? >> >> As you said yourself: rely on the atomic semantics of the filesystem. >> Rename it to an extension which the other program will not >> recognise, or >> into another directory which the other program won't be looking in. >> > > Perhaps you missed it in my original post (or perhaps I simply > wasn't clear), but I may be operating on files that are added > arbitrarily. My concern is that the script starts acting on a file > that is still being copied. Renaming it won't help there. Just use the renaming semantics in the first program (the one doing the copying) also. Basically you are using the filename appearance as a synchronization mechanism between the multiple processing steps. If you can't control the name of the file itself, then control the directory in which it appears. Gary Wright