You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,3 +2,36 @@ Dropbox-Folder-Size
2
2
===================
3
3
4
4
A small Python script that generates a .txt file of the sizes of your Dropbox folders. Perfect for checking the sizes of folders that you have selectively unsync-ed.
Still new to Dropbox development, so I'm not sure what the proper way of getting an access token is, but the way I did it was by:
14
+
15
+
1. Visiting [Dropbox's Developer site and going to App Console](https://www.dropbox.com/developers/apps).
16
+
2. Create a Dropbox API app with "Files and Datastores", "No", "All file types" options.
17
+
3. Get the app key, visit this [website](https://dbxoauth2.site44.com/) and it will generate an access token for you.
18
+
19
+
# Usage Instructions
20
+
21
+
Input your access token into the script.
22
+
23
+
The script accepts 2 variables:
24
+
25
+
1. Denominator (non-negative integer). 0 for bytes, 1 for KB, 2 for MB, 3 for GB, etc.
26
+
27
+
2. Levels (non-negative integer). Tells the script how far down the directory tree you want to look. E.g. if set to 1, the script will output the sizes of all your folders in the main Dropbox directory.
28
+
29
+
# Known Bugs
30
+
31
+
1. Dropbox still thinks .pages documents are folders. I might or might not get around to fixing this.
32
+
33
+
# Possible Features
34
+
35
+
1. Make this script a full-fledged app, with browser redirection for OAuth authentication and stuff.
36
+
2. Add support to run script in sub-folders.
37
+
3. Add a switch to un-ignore files that appear above the set level.
output.write('You are currently using '+str(usage) +' out of '+str(quota) +' of space on Dropbox.')
19
+
output.close()
20
+
quit()
21
+
22
+
sizes= {}
23
+
foldersizes= {}
24
+
cursor=None
25
+
26
+
whilecursorisNoneorresult['has_more']:
27
+
result=client.delta(cursor)
28
+
forpath, metadatainresult['entries']:
29
+
sizes[path] =metadata['bytes'] ifmetadataelse0
30
+
cursor=result['cursor']
31
+
32
+
forpath, sizeinsizes.items():
33
+
34
+
segments=path.split('/')
35
+
36
+
if (len(segments) >levels+1):
37
+
folder='/'.join(segments[0:levels+1])
38
+
else:
39
+
folder='/'.join(segments[0:len(segments)-1])
40
+
try:
41
+
foldersizes[folder] +=size
42
+
exceptKeyError:
43
+
foldersizes[folder] =size
44
+
45
+
if (denominator!=0):
46
+
forpath,sizeinfoldersizes.items():
47
+
ifsize:
48
+
foldersizes[path] =size/ (1024.0**denominator)
49
+
else:
50
+
delfoldersizes[path]
51
+
52
+
output=open('dropbox_folder_sizes.txt', 'w')
53
+
54
+
output.write('Below is a list of your largest Dropbox folders, ordered from largest to smallest. You chose a drill level of 2. Sizes are expressed as "%d", where 0 is in bytes, 1 is in KB, 2 is in MB, and 3 is in GB. \n'%denominator)
0 commit comments