Create a function for delete and copy files

Hi,
I need to create a function to delete files if exists and after deleting I need to copy one file to another...
I start to write

import java.io.File; // Import the File class
public class DeleteFile;
public static void main(String args)

  File f = new File("/data/hmi/M1/AUDIT/AuditTrail/~AuditTrail0.rdb");
     if(f.exists() && !f.isDirectory()) { 
    f.delete();

}
but I have a lot of alarms and I don't know why.....somebody can help me?

Mostly because node-red uses javascript not java. Apart from the name there is no relationship between the two.

Have a look at node-red-contrib-fs.

Use fs-ops

What are the relative merits of fs-ops vs fs?

As far as i can see, node-red-contrib-fs only lists files where as node-red-contrib-fs-ops has this capability + copy/delete/stats/move etc etc

and as the OPs title was "Create a function for delete and copy files" I figured fs-ops was the way to go.

U8QZ1Sj0Tc

Oh yes, sorry, I now realise I have both installed and thought those were from contrib-fs.
So yes, @PaulL you can use node-red-contrib-fs-ops and keep your javascript skills for when you really need them.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.