Hi all,
I am trying to incorporate the file.delete function into a macro and am able to get it to work if I use an "ImageJ" directory somewhere along the path, but it will not work if I use a "temp" folder. I have tried "temp", "tmp", "Temp", and "Tmp" with no luck. It is not imperitive to change it, but would make my files less confusing for someone else who may be using them. Also, is it possible to bypass the "1" that signifies that the file was deleted? Thanks |
Hi Robert,
As written in the documentation, for deleting the file must be in one of these - (1) in the user's home directory - (2) the ImageJ directory or - (3) the temp directory. Actually, any directory with "ImageJ" in the path will fulfil (2), so you can delete, e.g. /disk2/data/ImageJdata/myimage.tiff The temp directory for (3) is the one you get with getDirectory("temp"). To avoid the "1" in the log Window, assign the result to a variable: success = File.delete(myPath+myFilename); or if (!File.delete(myPath+myFilename)) exit("Delete failed"); Michael ________________________________________________________________ On 4 Sep 2008, at 20:57, Robert Barton wrote: > Hi all, > > I am trying to incorporate the file.delete function into a macro > and am > able to get it to work if I use an "ImageJ" directory somewhere > along the > path, but it will not work if I use a "temp" folder. I have > tried "temp", "tmp", "Temp", and "Tmp" with no luck. > > It is not imperitive to change it, but would make my files less > confusing > for someone else who may be using them. > > Also, is it possible to bypass the "1" that signifies that the file > was > deleted? > > Thanks |
If you didn't want the directory in one of the three locations Michael
listed, you could probably use the exec() function instead. It executes a system command, and the limitations would be dependent on the user's permissions. Linux exec("rm", "path"); Windows exec("cmd" , "/c" , "del", "path"); Justin On Mon, Sep 8, 2008 at 3:40 AM, Michael Schmid <[hidden email]> wrote: > Hi Robert, > > As written in the documentation, for deleting the file must be > in one of these > - (1) in the user's home directory > - (2) the ImageJ directory or > - (3) the temp directory. > > Actually, any directory with "ImageJ" in the path will fulfil > (2), so you can delete, e.g. /disk2/data/ImageJdata/myimage.tiff > > The temp directory for (3) is the one you get with > getDirectory("temp"). > > To avoid the "1" in the log Window, assign the result to a > variable: > success = File.delete(myPath+myFilename); > or > if (!File.delete(myPath+myFilename)) exit("Delete failed"); > > Michael > ________________________________________________________________ > > On 4 Sep 2008, at 20:57, Robert Barton wrote: > >> Hi all, >> >> I am trying to incorporate the file.delete function into a macro and am >> able to get it to work if I use an "ImageJ" directory somewhere along the >> path, but it will not work if I use a "temp" folder. I have >> tried "temp", "tmp", "Temp", and "Tmp" with no luck. >> >> It is not imperitive to change it, but would make my files less confusing >> for someone else who may be using them. >> >> Also, is it possible to bypass the "1" that signifies that the file was >> deleted? >> >> Thanks > |
Free forum by Nabble | Edit this page |