2011-11-22 76 views
7

我有一个文件夹在我的Dropbox 30,000文件,我不能删除使用Web界面。看来我必须下载所有30,000个文件才能告诉我的dropbox我真的不想要它们。使用Dropbox的Web界面来删除文件夹30,000文件

这个错误的出现是因为最初拥有这些文件的机器走了,我用的是选择性的同步,以避免下载30000个文件到我所有的其他计算机。

谁能想出一个聪明的办法来解决此问题?只是查看文件夹通常会导致Web界面崩溃。

+0

30,000个文件的总大小是多少? – Flukey

+0

@Flukey:可能500mb到1GB。他们很小。 – Zach

+0

我解决了这个问题,吸取它并等待12个小时,文件全部下载到另一台机器上。然后我删除了它们,现在它们都变成了桃色。 – Zach

回答

8

删除30,000文件的文件夹中的唯一方法是利用选择性同步下载它们。网页界面会出现“请使用桌面应用程序太多的文件”错误。它是自动化的,所以它唯一需要的是时间(以及足够的硬盘空间)。如果您没有足够的空间,请插入外部驱动器并重新指定Dropbox目录,让它下载,然后删除。

这是一个愚蠢的问题,我知道。我希望你可以通过网络界面管理更多,因为这是你文件的中心位置。

+1

不能相信它是2015年!仍然很棒的产品缺乏不那么明显但基本的特征 – nehemiah

+0

@itsneo 2015年,我们编写的每个应用程序仍然需要逐一编写“功能”。某处在编程演变的一些重大步骤缺失。只是我的两分钱。 – masterxilo

+0

但是,正如Jason指出的那样,“网络界面是所有文件的中心位置”,Dropbox应该投入更多资金和人才。但是我知道当DB开始的时候,这个意见是不同的,但是随着时间和这个流行产品的发展而变得偶然。 – nehemiah

1

我知道这是(略)晚,但对于其他人谁碰到这个问题绊倒,并有同样的问题...我的问题,特别是,我有数以百计的无不再需要档案演出的只有Dropbox服务器和我不想清理硬盘只是为了能够通过选择性同步删除它们。

从网络界面中删除很多文件仍然是不可能的,但如果您不介意潜入Dropbox API这至少可以实现自动化并且您不必使用自己的存储(我这样做了下面有Python SDK,但还有其他语言选项)。文件限制仍然适用,但可以对每个目录中的文件数进行计数,以确定删除它们的正确方法,而不会遇到问题。像这样:

下面的脚本需要作为输入您的独特的Dropbox API密钥和Dropbox目录列表(deleteDirList)。然后,它循环遍历deleteDirList每个元素的每个子目录,以确定是否有足够少的文件能够在没有达到限制的情况下删除目录(我将限制设置为保守的(?)10,000个文件);如果文件太多,它会逐个删除文件,直到计数低于限制。您需要安装Python包dropbox(我使用Anaconda,因此conda install dropbox

请记住,这是一种蛮力方法;每个子目录都会被逐个删除,这可能需要很长时间。一个更好的方法是统计每个子目录中的文件,然后确定可以删除而不触及限制的最高级目录,但不幸的是,我现在没有时间来实现这个目录。

import dropbox 




##### USER INPUT ##### 

appToken = r'DROPBOX APIv2 TOKEN' 
deleteDirList = ['/directoryToDelete1/','/directoryToDelete2/']  # list of Dropbox paths in UNIX format (where Dropbox root is specified as '/') within which all contents will be deleted. The script will go through these one at a time. These need to be separate directories; subdirectories will deleted in the loop and will throw an exception if listed here. 

###################### 




dbx = dropbox.Dropbox(appToken) 
modifyLimit = 10000 

# Loop through each path in deleteDirList 
for deleteStartDir in deleteDirList: 
    deleteStartDir = deleteStartDir.lower() 

    # Initialize pathList. This is the variable that records all directories down each path tree so that each directory is traversed, files counted, then deleted 
    pathList = [deleteStartDir] 

    # Deletion loop 
    try: 
     while 1: 

      # Determine if there is a subdirectory in the current directory. If not, set nextDir=False 
      nextDir = next((x.path_lower for x in dbx.files_list_folder(pathList[-1]).entries if isinstance(x,dropbox.files.FolderMetadata)),False) 

      if not not nextDir:  # if nextDir has a value, append the subdirectory to pathList 
       pathList.append(nextDir) 
      else:  # otherwise, delete the current directory 
       if len(pathList)<=1:  # if this is the root deletion directory (specified in deleteDirList), delete all files and keep folder 
        fileList = [x.path_lower for x in dbx.files_list_folder(pathList[-1]).entries] 
        print('Cannot delete start directory; removing final',len(fileList),'file(s)') 
        for filepath in fileList: 
         dbx.files_delete(filepath) 

        raise EOFError() # deletion script is complete 

       # Count the number of files. If fileCnt>=modifyLimit, remove files until fileCnt<modifyLimit, then delete the remainder of the directory 
       fileCnt = len(dbx.files_list_folder(pathList[-1]).entries) 
       if fileCnt<modifyLimit: 
        print('Deleting "{path}" and'.format(path=pathList[-1]),fileCnt,'file(s) within\n') 
       else: 
        print('Too many files to delete directory. Deleting',fileCnt-(modifyLimit+1),'file(s) to reduce count, then removing',pathList[-1],'\n') 
        fileList = [x.path_lower for x in dbx.files_list_folder(pathList[-1]).entries] 
        for filepath in fileList[-modifyLimit:]: 
         dbx.files_delete(filepath) 

       dbx.files_delete(pathList[-1]) 
       del pathList[-1] 

    except EOFError: 
     print('Deleted all relevant files and directories from "{}"'.format(deleteStartDir)) 
相关问题