利用python计算windows全盘文件md5值的脚本
import hashlib
import os
import time
import configparser
import uuid def test_file_md5(file_path):
test = hashlib.md5() if os.path.isfile(file_path):
with open(file_path, "rb") as f:
while True:
data = f.read(8096)
if not data:
break
else:
test.update(data)
ret = test.hexdigest()
config = configparser.ConfigParser() config.read("E:/python/pycharm/再开次开始/前端/test_md5.ini",encoding="utf-8")
if config.has_section(os.path.basename(file_path)):
new_section_name = str(os.path.basename(file_path)) + ":" + str(uuid.uuid4())
config[new_section_name] = {"文件路径":os.path.dirname(file_path),
"md5值":ret}
else:
config[os.path.basename(file_path)] = {"文件路径": os.path.dirname(file_path),
"md5值": ret}
config.write(open("E:/python/pycharm/再开次开始/前端/test_md5.ini","w",encoding="utf-8")) def test_dir_md5(file_path):
test_abs_path = os.path.abspath(file_path)
# print(test_abs_path)
os.chdir(test_abs_path)
for file in os.listdir(os.getcwd()):
if os.path.isfile(file):
test_file_md5(os.path.abspath(file))
elif os.path.isdir(file):
test_dir_md5(os.path.abspath(file))
else:
pass
# return True if __name__ == '__main__':
began_path = os.getcwd()
test_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(began_path))))
os.chdir(test_path)
print(os.listdir())
for test_file in os.listdir():
os.chdir(test_path)
if os.path.abspath(test_file).startswith("E:\\$"):
continue
else:
if os.path.isfile(test_file):
# print("yyyyy")
test_file_md5(os.path.abspath(test_file))
elif os.path.isdir(test_file):
# print("hahah")
test_dir_md5(os.path.abspath(test_file))
# print(os.path.abspath(test_file))
else:
pass
结果如下

利用python计算windows全盘文件md5值的脚本的更多相关文章
- java计算过G文件md5 值计算
package io.bigdata; import java.io.File; import java.io.FileInputStream; import java.io.IOException; ...
- windows查看文件MD5值的命令
今天需要,就记录一下. certutil -hashfile filename MD5 certutil -hashfile filename SHA1 certutil -hashfile file ...
- 利用Python计算π的值,并显示进度条
利用Python计算π的值,并显示进度条 第一步:下载tqdm 第二步;编写代码 from math import * from tqdm import tqdm from time import ...
- JAVA中获取文件MD5值的四种方法
JAVA中获取文件MD5值的四种方法其实都很类似,因为核心都是通过JAVA自带的MessageDigest类来实现.获取文件MD5值主要分为三个步骤,第一步获取文件的byte信息,第二步通过Messa ...
- 基于js-spark-md5前端js类库,快速获取文件Md5值
js-spark-md5是歪果仁开发的东西,有点多,但是我们只要一个js文件即可,具体类包我存在自己的oschina上,下载地址:https://git.oschina.net/jianqingwan ...
- C#统计目录中文件MD5值
1. [代码]统计目录中文件MD5值 using System.IO;using System.Security.Cryptography;using System.Collections;using ...
- MD5工具类,提供字符串MD5加密、文件MD5值获取(校验)功能
MD5工具类,提供字符串MD5加密(校验).文件MD5值获取(校验)功能 : package com.yzu.utils; import java.io.File; import java.io.Fi ...
- QT 获取文件MD5值
/* 方法1 */ QFile theFile(fileNamePath); theFile.open(QIODevice::ReadOnly); QByteArray ba = QCryptogra ...
- C# 获取文件MD5值的方法
可用于对比文件是否相同 /// <summary> /// 获取文件MD5值 /// </summary> /// <param name="fileName& ...
随机推荐
- 从Tomcat无法正常关闭讲讲Java线程关闭问题【转载】
正常情况下,会优先采用catalina.sh stop来停止Tomcat实例,这样可以让服务有机会处理完请求,并做好善后工作. 但如果通过catalina.sh stop命令无法关闭Tomcat实例, ...
- vlc 网页插件的 使用与控制 API http://www.xuebuyuan.com/2224602.html
不知道vlc 是什么的请百度一下.. vlc 提供了ie浏览器的activeX插件和火狐或者chrome的插件,基本上覆盖了所有浏览器,所以有复杂解码需求的情况下用vlc来解决网页播放视频,也是一种没 ...
- C++多线程同步之Mutex(互斥量)
原文链接: http://blog.csdn.net/olansefengye1/article/details/53086141 一.互斥量Mutex同步多线程 1.Win32平台 相关函数和头文件 ...
- css 元素选择器实例
一个完整的HTML页面是有很多不同的标签组成,而标签选择器,则是决定哪些标签采用相应的CSS样式.本文章向码农介绍css 标签/元素选择器以及其实例,需要的码农可以参考一下. [标签选择器] 一个完整 ...
- JavaScript中‘==’和'==='的区别
javascript中,两个等号‘==’和三个等号‘===’的区别: 简单说,‘===’比‘==’对相等的概念更为严格,使用‘==’时,数字 1 和 字符串 “1” 是相等的: 而使用‘===’时,数 ...
- zabbix微信报警
[root@LinuxS04 jiaoben]# ./weixin 联系人 baojing baojingok[root@LinuxS04 jiaoben]# pwd/usr/local/zabbix ...
- 进程和创建线程的两种方法(threading.Thread)
进程 如QQ 要以一个整体的形式暴露给操作系统管理,里面包含对各种资源的调用,内存的管理, 网络接口的调用等,进程就是各种资源管理的集合 线程:是操作系统最小的调度单位,是一串指令的结合 进程 要操作 ...
- License 校验
1:了解keytool 的一些命令 http://www.micmiu.com/lang/java/keytool-start-guide/ 本人在github找的一个demo:https://gi ...
- React 简单介绍
React 简单介绍 作者 RK_CODER 关注 2014.12.10 17:37* 字数 2516 阅读 55715评论 6喜欢 70 why React? React是Facebook开发的一款 ...
- mysql之explain
⊙ 使用EXPLAIN语法检查查询执行计划 ◎ 查看索引的使用情况 ◎ 查看行扫描情况 ⊙ 避免使用SELECT * ◎ 这会导致表的全扫描 ◎ 网络带宽会被浪费 话说工欲善其 ...