2011-11-22 75 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)) 
相關問題