我在google驱动器的根文件夹中有大约200k个扩展名为.tif的文件需要删除。在
我编写的python代码只传输/删除我们在实例中可以看到的少数文件(我们需要在驱动器中向下滚动,让它们“加载”以查看更多文件)
如果有快捷方式,我也愿意删除所有其他文件。在
Cntl+A也不起作用,它只是选择一些我们可以在实例中看到的文件。在
import shutil
import os
source = '/content/gdrive/My Drive'
dest1 = '/content/gdrive/My Drive/toDelete'
files = os.listdir(source)
for f in files:
if (f.endswith(".tif")):
shutil.move(f, dest1)
glob
。在pathlib
进行路径操作。在首先,您需要搜索名称中包含的、根目录中的所有文件,一旦找到这些文件,就可以开始删除它们。在
我建议您在不删除的情况下测试此项,以确保它列出的文件在我之后不负责此删除内容:)
page_token=无
相关问题 更多 >
编程相关推荐