From: Paul Archer Date: 2009-07-17T11:06:37+09:00 Subject: Re: making sure a file isn't being written/copied before moving Tomorrow, Gary Wright 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. > That still leaves me with the same problem: I have to read out of a directory. Plus, there isnt' just going to be a script putting files in my incoming directory. I'll be doing that myself as I clean up all my old files. Paul