# Conveniently downloading all the files in a CloudDirectory

Working on a data viz project online, I created a cloud directory with hundreds of plots I'd like to now download for final processing and visualization. Realistically, I'd just like to be able to right click and download the whole folder on the portal but that doesn't appear to be an option.

I've been working for hours today trying to get either CopyFile or CreateArchive to work with no results yet. Favouring the simpler approach at this point, I'd be happy if CreateArchive just took all the PNG files in the directory and compressed them into a zip in the same directory for download.

I tried the following code after setting the CloudDirectory to the path with all the PNGs in it with SetCloudDirectory, however it's just returned back to me without executing. The behaviour is not following some of the examples I found on stack-exchange or in the docs.

test = CloudDirectory[];
CreateArchive[test, "test.zip"]


returns:

CreateArchive[CloudObject[https://www.wolframcloud.com/obj/user/Projects/05%20Seismic%20Project/posterframes],test.zip]


Judging from the docs page, it should return the path of the new archive file.

## 2 Answers

Here's an example of how you can do this. Go on the web interface, make the ZIP there, then copy it to a CloudObject. E.g.:

meep=CreateArchive[Directory[]<>"/author", "test.zip"];
CopyFile[meep, CloudObject["test.zip"]]


You may want to change up the permissions, like CloudObject["test.zip", Permissions->"Public"]

Clicking on the link to that CloudObject will now download the ZIP

• I can't get this approach to work sadly. I'm failing right at step one Directory[]<>"/author". I tried all sorts of combinations of URLs and strings, and it failed every time to find the directory the plots were in. Could this be a problem with the Wolfram cloud perhaps? – BBirdsell Jan 14 at 5:20
• I used Directory[]/author just because I had less in it. You should use whichever directory is pertinent to you. – b3m2a1 Jan 14 at 5:21
• Yeah I tried two main approaches (with variations). A full string path similar to the one I used to export all the plots to the directory in the first place. And secondly, the set CloudDirectory. Both failed. I'm just wondering why I can reproduce this. I exported to this path in the notebook."https://www.wolframcloud.com/obj/user/Projects/05%20Seismic%20Project/posterframes – BBirdsell Jan 14 at 15:21
• You can see what directories you have by evaluating FileNames["*", Directory[]] in the cloud interface – b3m2a1 Jan 14 at 17:02
• Unfortunately Directory[] on the cloud doesn't give the same behaviour as Desktop Mathematica. CloudDirectory[] does not seem to work with CreateArchive. It will always fail with the "file or directory not found". This behaviour changes how FileNames works too. Pointed at the full directory of plotted PNGs it files nothing. – BBirdsell Jan 18 at 1:41

You can use CopyDirectory.


In[11]:= CloudObjects["test", All]

Out[11]= {CloudObject[
"https://www.wolframcloud.com/obj/damanjits/test/destDir"], \
CloudObject[
"https://www.wolframcloud.com/obj/damanjits/test/myDesktopFile.nb"], \
CloudObject[
"https://www.wolframcloud.com/obj/damanjits/test/myNewAPI"], \
CloudObject[
"https://www.wolframcloud.com/obj/damanjits/test/namedObj"], \
CloudObject[
"https://www.wolframcloud.com/obj/damanjits/test/obj"], CloudObject[
"https://www.wolframcloud.com/obj/damanjits/test/provoceBug"]}

In[7]:= CopyDirectory[CloudObject["test"], "/tmp/cloudTestDir"]

Out[7]= "/tmp/cloudTestDir"

In[12]:= FileNames[All, "/tmp/cloudTestDir", Infinity] // Column

Out[12]=
/tmp/cloudTestDir/destDir
/tmp/cloudTestDir/destDir/conflower.jpg
/tmp/cloudTestDir/myDesktopFile.nb
/tmp/cloudTestDir/myNewAPI
/tmp/cloudTestDir/namedObj
/tmp/cloudTestDir/obj
/tmp/cloudTestDir/provoceBug



We will add this usage in ref/CopyDirectory. Thank You.

• This would work if I had a desktop kernel to work with. Alas.. I'm cloud only for the moment. Is there an alternative to this? I know this is an edge case perhaps but there's mathematicians everywhere. – BBirdsell Jan 16 at 4:05