Renaming files in a wordpress folder via jquery / jscript

I am trying to run a script that will run every 5 minutes in a shared hostings wordpress folder that will rename the newest CSV file in that folder.

/wp-content/csv/sample.csv

I tried putting a js file in the folder within that folder and run it.

var fs = require('fs');

function runClear() 
{
    fs.readdir("", (err, files) => {
      files.forEach(file => {
        console.log(file);
      });
    })    
}

runClear();
setInterval(runClear, 300*1000);

However, it seems like I got client side and server side scripting confused. It seems like I need node.js.

What would be the best approach for this?

Regards,

Read more here: Renaming files in a wordpress folder via jquery / jscript

Leave a Reply

Your email address will not be published. Required fields are marked *