Workflow to create a new folder in drive

Hi, I have a question about file management. I’m using Google Sheets and have a table called Locations and another one called Uploaded Images. The Uploaded Images table makes rows that I can upload an image to and associate it with a ref to a Location. It saves these files in my drive in a folder called Uploaded Images_Images and I made it so that their file name is the “Location they’re associated with” followed by a UniqueID(). It works okay but I’m wondering if there is a way to automatically create a folder in my drive for each Location I have and for the files to then be saved there?

You can do it with google apps script. I can share some code sample if you need it.

1 Like

Yes please, that would be outstanding!

Why would you like to create them by yourself? Why don’t you just let the app to create those folders when new image is saved and it needs a new folder?

1 Like

Whichever solution works. So far in my understanding of appsheet, I know how to reassign where an image gets saved to but I don’t understand how to have the app generate folders beyond the default way of making a folder to contain all the images uploaded to a table. I’m trying to have a folder created for basically every row in my Locations table that I would then save the images from the table Uploaded Images to.

I agree with Aleksi.

Image/File folder path, we are able to use expression.
That means we are dynamically change the path, borrowing values from the row you are currently editing to save image or even borrow the value from other table, usersetting etc.

1 Like

I’m not sure AppSheet will create non-existent directories, though. This isn’t a feature I use so I can’t speak from experience.

As far as I know, it would generate the non-existing folder. Appsheet is smart enough!

1 Like

Intriguing. Do you have any suggestions for an expression that would give that result to put in for the Image/file folder path?

In the past, I noticed by accident. I saved the files with name “/” within the name of the file/image under the workflow.
The appsheet split by “/”, before “/” as folder name and after “/”, as file name.

I could not locate the file on the target folder, but actually I generated the new folder without knowing that…

That s the reason I believe it would work.

1 Like

For that table, you generate the name of folder you wish to have. and place that column name into it.

I m not testing physically with my app, but I suppose

/appsheet/data/{your app name-id}/[Column name]

should work. But I need to borrow the thought from Aleski and Steve, to see if I m on the right track!

@Aleksi
@Steve

Sure, here’s what I tried so far and it gave me this error

How about

“appsheet/data/TheFootprintProject2-1028762/”&[Station Site]

just construct the string.

2 Likes

Well that seemed to have done it! So now when my Uploaded Images table adds a new row I changed the image column to that file path and now it creates a folder if there wasn’t one and adds the image to one if it already existed!
Thank you!

Excellent!!!

Actually, I tried it shortened just to [Station Site] and it made the folder just in the drive where I have my spreadsheet simple as that.
So I guess it is really pretty simple. If there is no folder existing, you can just put in a column name and it will save the images in a folder named that!

2 Likes

Thanks for sharing your experience, I learned lesson from you for my own future case.

Anyway, great to hear you now solved issue.

2 Likes

This is perfect for my project, thank you!

1 Like

FYI… if you try to use date as a key value like 01/31/2020.Image.01312020_010145 it will generate subfolders like 01 > 31 > 2020 > Images.

4 Likes