Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Recursively list all files in Dropbox:
./pydbxcli.py ls -r /
```

Recursively list all files in Dropbox excluding certian folders:
```bash
./pydbxcli.py ls -r '/' --excludePaths '/Team Folder/IgnoreThisFolder' '/Team Folder/IgnoreThisFolderToo'
```

Recursively download specific Dropbox directory to local directory
```bash
./pydbxcli.py get -r /mystuff/dropbox/dir ./localdir
Expand Down
24 changes: 24 additions & 0 deletions pydbxcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def main():
type=str,
default='/',
help='which path from which to list')
parser_ls.add_argument('--excludePaths',
nargs='*',
default=[],
help=("a list of folder paths to ignore. "
"example: --excludePaths '/Team Folders/IgnoreThisFolder' "
"'/Team Folders/IgnoreThisFolderToo'")
)
parser_ls.set_defaults(func=ls)

# create the parser for the "get" command
Expand All @@ -64,6 +71,13 @@ def main():
type=str,
default='.',
help='which path on the local machine to store downloads')
parser_ls.add_argument('--excludePaths',
nargs='*',
default=[],
help=("a list of folder paths to ignore. "
"example: --excludePaths '/Team Folders/IgnoreThisFolder' "
"'/Team Folders/IgnoreThisFolderToo'")
)
parser_ls.set_defaults(func=get)

# parse the args and call the selected command function default to help and version
Expand Down Expand Up @@ -98,6 +112,11 @@ def ls(args):
while True:
files = dbx.files_list_folder(path=args.path, recursive=args.r)
for entry in files.entries:
#skip any paths specified in --excludePaths
if any(map(getattr(entry, 'path_display').startswith, args.excludePaths)):
print('Excluding {}'.format(getattr(entry, 'path_display')))
continue

print('{:>8} {:>20} {}'.format(sizeof_fmt(getattr(entry, 'size', 0)),
str(getattr(entry, 'client_modified', '-')),
getattr(entry, 'path_display', '-')))
Expand All @@ -116,6 +135,11 @@ def get(args):
files = dbx.files_list_folder(path=args.src_path, recursive=args.r)
while True:
for entry in files.entries:
# skip any paths specified in --excludePaths
if any(map(getattr(entry, 'path_display').startswith, args.excludePaths)):
print('Excluding {}'.format(getattr(entry, 'path_display')))
continue

size = getattr(entry, 'size', None)
# skip empty files and directories
if not size:
Expand Down