Hello friends! From the series “understanding about exporting, importing files”, this time I would like to import all files from a folder with an option to include subfolder files if they exist.
Here I arrived at a functional result:
try {
const fs = require('uxp').storage.localFileSystem;
await core.executeAsModal( async () => {
const directory = await fs.getFolder();
const persistentToken = await fs.createPersistentToken(directory);
localStorage.setItem("persistentFolder", persistentToken);
const token = localStorage.getItem("persistentFolder");
const thePersistentFolder = await fs.getEntryForPersistentToken(token);
const ckSubfolder = document.querySelector("#ckSubf")
if(ckSubfolder.checked){alert("Marcado")}
const getFiles = await thePersistentFolder.getEntries();
for (var i=0;i<getFiles.length;i++){
/// SCRIPTS AQUI-------
app.open(getFiles[i]);
alert("FUNCTIONS HERE!")
/// =============
}
})
}
catch (e) {alert(e); console.log(e);}
But the script does not import the subfolder files, and my request is to be able to include them using a true to false checkbox, but I have no idea how to add this to my code.
Please, some wiser and more experienced friend on the subject could guide me, show me how to add the code snippet that allows such a feat.
const ckSubfolder = document.querySelector("#ckSubf")
if(ckSubfolder.checked){///CODE INCLUDE SUBFOLDER FILES}