I have a spreadsheet with actual data and one with archived data. I've created to behaviour: First, I copy one entry to the archive spreadsheet if a value is true. Second, the entry is deleted in the actual data spreadsheet. This works fine.
However, the image which is saved in the automatically created folder when I create a new entry stays in this folder. Is there a possibility to also move it in an archive folder? or copy it to the archive folder and delete it in the actual data folder? or add an additional part like "_archive" at the end of the image name?
and I don't get only the name of the image in the archive spreadsheet, but a url link directly going to the image. Though I'd prefer having the name and not a link.
>>"Is there a possibility to also move it in an archive folder? or copy it to the archive folder and delete it in the actual data folder? or add an additional part like "_archive" at the end of the image name"
Not with Appsheet. You can use Google App Script to handle that.
Do you mean, I can write a script which I can use in Appsheet to move the files in another folder?
I've never used Google App Script.
Yes an App Script can move files, for example the following would work assuming you have the IDs of the file and the folder you want to move it to:
function moveFiles(sourceFileId, targetFolderId) {
var file = DriveApp.getFileById(sourceFileId);
var folder = DriveApp.getFolderById(targetFolderId);
file.moveTo(folder);
}
Thanks a lot @graham_howe ! I only do have the filename in a column of the spreadsheet in google drive and the default folder which appsheet creates for taking the first photo. How can I get the ID's of these?
You would need to use Apps Script to also get the file ID based on the name. This is a bit more difficult because the file name is not unique and so you can end up with multiple results. A quick search provided the following code which would work to generate an array of file IDs matching the file name within the folder. I would caution however that this is starting to get a little complicated and is certainly moving well beyond the 'no code' or 'low code' principles of AppSheet.
function findFilesInfo(folderId, fileName) {
var folder = DriveApp.getFolderById(folderId);
var files = folder.getFilesByName(fileName);
var fileIDs = [];
while (files.hasNext()) {
var file = files.next();
fileIDs.push(file.getId());
}
return fileIDs;
}
by filename I mean the name Appsheet automatically gives the photo-file when adding a data point including taking a photo (looks like: 05-09-2022 13-26-05.image_1.112705.jpg). so I hope this is kind of unique?
and this moving of images should be connected with the Behavior which does this: "Data: add a new row to another table using values from this row". And this row can have up to 5 images.
AppSheet provides no way to move files.
What about a way to select a file from an image type column and re uploading it onto another column with a different storage folder path?
User | Count |
---|---|
14 | |
11 | |
9 | |
7 | |
4 |