node.jselectronfschild-processfs-extra

Best way to copy a directory from an external drive to a local folder with electronjs?


Just wondering if anyone has ever attempted to copy a directory from an external drive (connected via USB) to a local folder.

I am using ElectronJS so I can use my JavaScript, HTML/CSS skills to create a desktop application without utilising a C language. (i.e. C# or C++) With ElectronJS there's a lot less to worry about.

Here is the list of things I've tried so far:

fs.moveSync is not a function even though Visual Studio Code brought up moveSync as a suggestion when I entered fs. (ctrl + space)

Then bundled with browserify. Bundle.js is then imported into the html file and the test function is called on the click of a button. I'm aware the command is ipconfig for now, this was merely used to see if a command could be executed. It appears it could because I was getting process.exec is not defined.

The exposed functions within this module were also reported as being undefined. And I thought about the use case longer I thought a simple copy process would suffice because external drive can be accessed like any other folder in the file explorer.

Unfortunately, all of the above have failed and I've spent the most part of the day looking for alternative modules and/or solutions.

Thanks in advance because any help to achieve this would be much appreciated.

Thanks

Patrick


Solution

  • Ended up adding this to my preload.js for:

    window.require = require;
    

    It will work for now but is due to be depreciated. I'll use this for now and make other updates when I have to.