I am new to electron and this forum, I want to move a file to a certain location on a computer with a drag and drop of a file in an electron program using child_process. the file must be moved on the click of a button, here is my code:
document.addEventListener('dragover', (e) => {
e.preventDefault();
e.stopPropagation();
});
document.addEventListener('drop', (event) => {
event.preventDefault();
event.stopPropagation();
let pathArr = [];
for (const f of event.dataTransfer.files) {
// Using the path attribute to get absolute file path
console.log('File Path of dragged files: ', f.path)
pathArr.push(f.path); // assemble array for main.js
const apply = document.getElementById('apply')
apply.addEventListener('click', () => {
applyTheme()
});
async function applyTheme() {
const { stdout, stderr } = await exec('mv ', f.path, ' %userprofile%\\.spicetify\\Themes');
if (stderr) {
console.error(`error: ${stderr}`);
}
console.log(`${stdout}`);
};
}
console.log(pathArr);
});
but I get this error:
Uncaught (in promise) TypeError: The argument 'args' is invalid. Received ' %userprofile%\\.spicetify\\Themes'
at __node_internal_captureLargerStackTrace (node:internal/errors:464)
at new NodeError (node:internal/errors:371)
at Object.execFile (node:child_process:312)
at Object.t.<computed> [as execFile] (node:electron/js2c/asar_bundle:5)
at exec (node:child_process:235)
at node:child_process:244
at node:electron/js2c/asar_bundle:5
at applyTheme (renderer.js:101)
at HTMLButtonElement.<anonymous> (renderer.js:98)