Dropbox Core API 超过10000个文件移动策略

0 投票
1 回答
667 浏览
提问于 2025-04-18 13:58

我把大约50,000个文件的iPhoto库同步到了Dropbox文件夹,但我想把它移动到另一个文件夹。当我尝试通过dropbox.com移动这个文件夹时,它提示“文件太多,请使用桌面应用程序”。于是我安装了Python的Dropbox库(用命令pip install dropbox),按照教程设置了代码并运行了:

db_client2.file_move('/Personal Pictures/iPhoto Library', '/temp/iPhoto Library')

根据文档的说明,文件数量限制是10,000个:

dropbox.rest.ErrorResponse: [406] u'There are too many files involved in this operation.'

你们用什么方法来移动这么多文件的单个文件夹呢?

1 个回答

0

这个解决方案虽然“慢”,但可以不需要人看着:

files= list_files(db_client2, path_prefix='/Personal Pictures/iPhoto Library', include_media_info=True)

for k, v in files.iteritems():
    final_path = k.replace('/personal pictures/', '/temp/')
    if v['is_dir'] == True:
        print k + " is a dir and is skipped"
    else:
        db_client2.file_move(k, final_path)
        print "moved " + k

撰写回答