恢复百度云盘本地误删的文件脚本---python
来源:互联网 发布:宿舍网络搭建 编辑:程序博客网 时间:2024/06/16 08:06
今天被同步盘搞得焦头烂额。
辛苦码的代码(除了重要的、备份过的)都被删掉了……
当时我就石化了。。。
随后发现同步盘目录有个delete目录,里面还有manifest.xml,和一堆改了名的文件,
看到manifest.xml的内容时,瞬间觉得有救了,立马开搞python
废话不多说,直接上代码:
#-*- coding:utf-8 -*-from xml.etree import ElementTreeimport osimport sysreload(sys)sys.setdefaultencoding( "utf-8" )def convertfile(cachePath,orgPath): '''恢复文件''' start=0; while True: index = orgPath.find('\\', start) if index == -1: break start = index + 1 orgDir=orgPath[:start] print 'orgDir:',orgDir if not os.path.exists(orgDir): os.makedirs(orgDir) if not os.path.exists(orgPath) or(os.path.exists(orgPath) and (os.path.getsize(orgPath) != os.path.getsize(cachePath))): file_in=open(cachePath, "rb") file_out=open(orgPath, "wb") file_out.write(file_in.read()) file_in.close() file_out.close() def read_xml(text): '''读xml文件''' root = ElementTree.fromstring(text) lst_node = root.getiterator("record") for node in lst_node: cp=node.attrib['cachePath'] op=node.attrib['orgPath'] cp=cp.replace('~','.') op=op.replace('~','.') print cp+'->'+op convertfile(cp,op) if __name__ == '__main__': '''将本文件放在云同步盘的根目录下, 将mani_file改为需要恢复的manifest文件''' mani_file=".\\.baohe.cache\\.delete\\20140412\\manifest.xml" read_xml(open(mani_file).read())
本文件在Python2.7.6下正常,3.4貌似有问题(汗
python可以在官网下载:https://www.python.org/downloads/
将本文件(假如叫做huifu.py)放在云同步盘的根目录下,比如云同步盘在“d:\baiduyun\”,那么文件应该在“d:\baiduyun\”下,最终是这样的“d:\baiduyun\huifu.py”
0 0
- 恢复百度云盘本地误删的文件脚本---python
- 恢复误删的本地分支
- git如何恢复本地删除的文件
- GitHub恢复本地被删除的文件
- 用于转换和恢复从ipa文件中,提取到的png文件的Python脚本 支持Python 3.3版本
- 安全删除和恢复文件的脚本
- 恢复正在运行的脚本到文件
- 恢复误删的文件
- Python 脚本分析(ftp上传文件、获取本地时间)
- linux服务器本地和百度云备份脚本小试
- git 误删的本地分支恢复方法
- eclipse 误删文件的恢复,代码的恢复
- eclipse 误删文件的恢复,代码的恢复
- eclipse 误删文件的恢复,代码的恢复
- eclipse 误删文件的恢复,代码的恢复
- Eclipse从SVN恢复本地<误删除已删除>的文件和代码
- Eclipse从SVN恢复本地<误删除已删除>的文件和代码
- Eclipse从SVN恢复本地<误删除已删除>的文件和代码
- Linux中常用的网络命令
- Linux动态库与静态库的制作
- 冒泡算法
- Android利用ContentResolver查询的三种方式
- Linux设备驱动之HID驱动
- 恢复百度云盘本地误删的文件脚本---python
- 解决Camera.parameter.setPreviewSize/Camera.parameter.setPictureSize适应不同手机问题
- sip over tcp or udp
- 怎么让背景图不随页面滚动
- 关于数据库的链接查询
- 无线网络安全攻防
- 约瑟夫环问题
- 数据库JDBC驱动及URL介绍
- scp