9
$\begingroup$

I have recently been saving my files to Wolfram Cloud for convenience as I am using different computers for work.

I would like to routinely back up the files to my local desktop.

If I were to do this I would need to click each file in the cloud one by one and manually click download.

Is there a way I can write a notebook to do this automatically as I have 100+ files and I would like to do this job quite regularly?

$\endgroup$

2 Answers 2

11
$\begingroup$

You can use CloudObjects and CloudDirectory to find your files:

objects = CloudObjects @ CloudDirectory[]
{CloudObject["https://www.wolframcloud.com/obj/carlw/Base"], CloudObject[
"https://www.wolframcloud.com/obj/carlw/Copied Files"], CloudObject[
"https://www.wolframcloud.com/obj/carlw/Marathon"], CloudObject[
"https://www.wolframcloud.com/obj/carlw/Resources"], CloudObject[
"https://www.wolframcloud.com/obj/carlw/marathon"], CloudObject[
"https://www.wolframcloud.com/obj/carlw/trash"]}

Here is the first cloud object in the "Copied Files" directory:

obj = First @ CloudObjects[objects[[2]]]
CloudObject["https://www.wolframcloud.com/obj/carlw/Copied Files/01-starting-out-elementary-arithmetic-exercises.nb"]

Once you find the right directory, you can copy them with CopyFile:

CopyFile[obj, FileNameTake @ Information[obj]["Path"]]
"/Users/carlw/Desktop/01-starting-out-elementary-arithmetic-exercises.nb"
$\endgroup$
1
5
$\begingroup$

This is the code I ended up using. It also looks into directories 1 level and copies those files too.

localBackupPath = "C:\\Users\\";
objects = CloudObjects@CloudDirectory[];
type = Information[#, "FileType"] & /@ objects;
allObjects = 
  Flatten[MapThread[
    If[#2 === Directory, CloudObjects[#1], #1] &, {objects, type}]];

CopyFile[#, 
   FileNameJoin[{localBackupPath, 
     Information[#, "DisplayName"]}]] & /@ allObjects
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.