如何更改dat文件格式(dat文件的打开方式)

微信已经成为非常重要的社交工具了,但是随着使用的年限增加,微信会产生大量的文件占据手机磁盘空间,而且很多文件都是dat格式,不能正常打开。

如何更改dat文件格式(dat文件的打开方式)

1.dat文件路径 (确保已有路径,或自己修改)

into_path = r'C:image'  # 微信image.dat文件路径  

2.输出图片路径

out_path = r"C:imagejpg\"

3.输入代码

# weixin_Image.dat 破解# JPG 16进制 FF D8 FF# PNG 16进制 89 50 4e 47# GIF 16进制 47 49 46 38# 微信.bat 16进制 a1 86----->jpg  ab 8c----jpg     dd 04 --->png# 自动计算异或 值import osinto_path = r'C:image'  # 微信image.dat文件路径   #我这把路径写死了,运行可执行文件前 先创建这个路径把dat文件放在这out_path = r"C:imagejpg\""""    解码    param f: 微信图片路径    param fn:微信图片目录下的.dat    return:"""def imageDecode(f, fn):    dat_read = open(f, "rb")  # 读取.dat 文件    xo = Format(f)  # 判断图片格式 并计算返回异或值     out = out_path + fn + ".jpg"  # 图片输出路径    print("文件输出路径{}".format(out), end='nn')    png_write = open(out, "wb")  # 图片写入    dat_read.seek(0)  # 重置文件指针位置    for now in dat_read:  # 循环字节        for nowByte in now:            newByte = nowByte ^ xo  # 转码计算            png_write.write(bytes([newByte]))  # 转码后重新写入    dat_read.close()    png_write.close()def findFile(f):    """    寻找文件    param f:微信图片路径    return:    """    fsinfo = os.listdir(f)  # 把路径文件夹下的文件以列表呈现    print(fsinfo)    for fn in fsinfo:  # 逐步读取文件        temp_path = os.path.join(f, fn)  # 拼接路径:微信图片路径+图片名        if os.path.isfile(temp_path):  # 判断目录还是.dat  #temp_path需为绝对路径,判断是否为文件,也可 if not os.path.isdir(temp_path):            print('找到文件路径{}'.format(temp_path))            fn = fn[:-4]  # 截取字符串 去掉后缀.dat            imageDecode(temp_path, fn)  # 转码函数        else:            passdef Format(f):    """    计算异或值    各图片头部信息    jpeg:ff d8 ff    png:89 50 4e 47    gif: 47 49 46 38        """    dat_r = open(f, "rb")    try:        a = [(0x89, 0x50, 0x4e), (0x47, 0x49, 0x46), (0xff, 0xd8, 0xff)]        for now in dat_r:            for xor in a:                i = 0                res = []                nowg = now[:3]#取前三个 数据信息                for nowByte in nowg:                    res.append(nowByte ^ xor[i])#进行判断                    i += 1                if res[0] == res[1] == res[2]:#三次异或值想等 说明就是那种格式                    return res[0]#返回异或值    except:        pass    finally:        dat_r.close()# 运行if __name__ == '__main__':    findFile(into_path)

也可以直接使用打包好的exe软件

注意

dat文件路径:C:image  没有先创建好 将要转换的微信dat文件 放到此处图片输出路径:C:imagejpg

转码后只要不删除dat,不选择删除源文件,是不会有影响的。软件会读取文件,并转码后重新生成文件,并与源文件同名。

我们可以根据文件名进行排序或根据类型进行排序,然后对文件进行处理。

(0)
小多多的头像小多多创始人

相关推荐

发表回复

登录后才能评论