美文网首页
工具分享 | 如何制作百度网盘中的文件目录?

工具分享 | 如何制作百度网盘中的文件目录?

作者: 永恒君的百宝箱 | 来源:发表于2020-11-04 20:01 被阅读0次

不知道大家有没有需要获取百度网盘中的文件的目录

永恒君在百度网盘里面存了大量文件,有时候需要做分享时候,希望可以把资源文件做一个目录列表,这样更方便使用。如下图

百度云客户端本身并不提供这个功能,经过一番搜索和研究,发现网上已经有大神用python开发出来了小工具,只需要直接拿来用就好了。python源代码如下:

#!/usr/bin/env python3

# -*- coding:utf-8 -*-

fromtkinterimport*

fromtkinter.filedialogimportaskopenfilename

fromtkinter.filedialogimportasksaveasfilename

fromtkinter.ttkimport*

importsqlite3

defselect_db_file():

db_file = askopenfilename(title="请选择BaiduYunCacheFileV0.db文件",filetypes=[('db','*.db')])

db.set(db_file)

defselect_save_file():

save_file = asksaveasfilename(filetypes=[('文件','*.txt')])

f.set(save_file+".txt")

defwrite_file(file_dict,f,item,gap=""):

ifitem=="/":

f.write("━"+"/"+"\n")

foriinfile_dict["/"]:

f.write("┣"+"━"+ i +"\n")

i = item + i +"/"

ifiinfile_dict:

write_file(file_dict,f,i, gap="┣━")

else:

gap ="┃  "+ gap

foriinfile_dict[item]:

f.write(gap + i +"\n")

i = item + i +"/"

ifiinfile_dict:

write_file(file_dict,f,i,gap)

defcreate_baiduyun_filelist():

file_dict = {}

conn = sqlite3.connect(db.get())

cursor = conn.cursor()

cursor.execute("select * from cache_file")

whileTrue:

value = cursor.fetchone()

ifnotvalue:

break

path = value[2]

name = value[3]

size = value[4]

isdir = value[6]

ifpathnotinfile_dict:

file_dict[path] = []

file_dict[path].append(name)

else:

file_dict[path].append(name)

withopen(f.get(),"w",encoding='utf-8')asfp:

write_file(file_dict,fp,"/")

root = Tk()

root.title('百度云文件列表生成工具')

db_select = Button(root, text=' 选择DB文件 ',command=select_db_file)

db_select.grid(row=1,column=1,sticky=W,padx=(2,0),pady=(2,0))

db = StringVar()

db_path = Entry(root,width=80,textvariable = db)

db_path['state'] ='readonly'

db_path.grid(row=1,column=2,padx=3,pady=3,sticky=W+E)

save_path = Button(root, text='选择保存地址',command=select_save_file)

save_path.grid(row=2,column=1,sticky=W,padx=(2,0),pady=(2,0))

f = StringVar()

file_path = Entry(root,width=80,textvariable = f)

file_path['state'] ='readonly'

file_path.grid(row=2, column=2,padx=3,pady=3,sticky=W+E)

create_btn = Button(root, text='生成文件列表',command=create_baiduyun_filelist)

create_btn.grid(row=3,column=1,columnspan=2,pady=(0,2))

root.columnconfigure(2, weight=1)

root.mainloop()

工具的原理:

百度网盘客户端会将云盘中的所有文件路径缓存在本地磁盘上,并保存为一个数据库文件(BaiduYunCacheFileV0.db),只需要找到合适的工具读取这个数据库即可制作百度网盘中的文件目录。

使用方法:

将上面的代码保存为.py文件,直接运行后会出现下面的界面,

选择BaiduYunCacheFileV0.db的路径,然后选择要保存目录的txt的位置,然后点击“生成文件列表”即可。

这个工具着实很方便!!!

如果你嫌麻烦,可以直接下载永恒君制作好的.py文件使用。

另外,考虑到有些朋友的电脑上可能没有安装python,永恒君也把python文件编译成了exe文件,直接双击即可运行

py文件和exe文件都打包放在后台了,感兴趣的话公号内回复"云目录"自取吧~~~

欢迎交流!

你可能还会想看:

长图片如何分页打印?3秒搞定

又一款在线文件分享工具,无需注册,支持阅后即焚

多数人不知道的电脑连接手机的方法,十分方便快捷!

【技巧】如何将你手机里的app分享给其他人?

忘记windows密码怎么办?

推荐三个英文学习的好工具

网页视频加速神器,提升你的学习效率!

相关文章

网友评论

      本文标题:工具分享 | 如何制作百度网盘中的文件目录?

      本文链接:https://www.haomeiwen.com/subject/rdqnvktx.html