Auto download and rename, the data collected using odk collect

Can we download the photographs automatically from the link?

For example: I have attached my excel. I need to download the google drive link automatically and the file name should rename to the custom name which I want. This is the sample data I need to do this for larger files.

Is there any queries to download ?

If there are any methods please share with me. sample-odk forum.xlsx (12.2 KB)

1 Like

Hello @Thalavaipandi,

It's kind of hard to help you because you didn't give us so much to go on here. For starters, are you able to write code? If you are, which language do you often use? I am certain the many power users here will be able to get you on the right path with a little more help.

That said, I'll throw in this to at least help the situation a bit. cURL, used below, is cross platform so it should work regardless. You can have a program or script that obtains the data in the data-treedetails-observations-image column and truncates the part after ?id=
So for the first record in the file you attached, you will need to extract 1jog99LeRijRhpLv0eu3cch8jsok0-Xwc from https://drive.google.com/open?id=1jog99LeRijRhpLv0eu3cch8jsok0-Xwc

The next step is to open up terminal or command prompt and use

curl -L -o [desiredName] "https://drive.google.com/uc?export=download&id=[fileID]"

making sure to replace [desiredName] with the custom name and [fileID] with the string you extracted in the previous step. So to download the first record to your device and renamed to image3.jpg you will need to use

curl -L -o image3.jpg "https://drive.google.com/uc?export=download&id=1jog99LeRijRhpLv0eu3cch8jsok0-Xwc"

For files greater than 40MB though, you may need to consult this post.

2 Likes

man I think your answer can be useful to me... could you explain me better how this "curl" function works, I can download the photos from the links massively, because sometimes there are more than 2 thousand photos in the googlesheet column...
can you tell me if just by the prompt i can do this, or i have to develop some small program?

do you know if i can also rename all files downloaded automatically ??
thanks !! I'm waiting,

Hello @BrunoAngelo, nice to meet you.
I am happy to hear my post helped you too. As I mentioned in my post earlier cURL is an open-source, cross platform program that can be used to transfer data via URLs. You can learn more about it here

I understand you have a lot of items to download and would love to automate this. I believe it should be fairly easy to integrate cURL in a small program with a well defined loop to do this for you. On the matter of renaming downloaded files, kindly refer to

You'll just need to replace [desiredName] with whatever name you want.

Hope you find this helpful.

1 Like