I am creating Text files with a Google script I found from here
They save by default in my Google Drive.
I want to save them in a specific called folder called TextFiles in my Google drive
create text files with
function dlFile(str) {
let file = DriveApp.getRootFolder().createFile('Hi.txt', str);
// Create little HTML popup with the URL of the download
let htmlTemplate = HtmlService.createTemplateFromFile('download.html');
htmlTemplate.dataFromServerTemplate = { url: file.getDownloadUrl() };
let html = htmlTemplate
.evaluate()
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi()
.showModalDialog(html, 'download');
};
HTML
<input type="button" value="download" onclick="getUrl()" />
<script>
function getUrl() {
google.script.run.withSuccessHandler(download).getDownloadUrl();
}
function download(obj) {
var d = document.createElement('a');
d.href = obj.url;
d.download = obj.filename;
d.click();
}
</script>
How to save these to an existing folder called TextFiles
Thanks