.var files checker v01

Other .var files checker v01

ruinousdeity

Member
Messages
14
Reactions
26
Points
13
ruinousdeity submitted a new resource:

.var files checker v01 - var checker

View attachment 245503

Under normal circumstances, unless we decompress all our .var files or encounter errors when loading these .var files with VAM, we cannot understand whether the .var files were fully downloaded at the beginning or if the file content is actually damaged. We can use this simple script to understand if there are issues with the .var files. This script will display the current progress and the final check result list.

Let me clarify here that I am a user...

Read more about this resource...
 
Assuming anyone has concerns about the script content, here is the script. You can directly copy, check, and paste it into a text editor to generate the script:;)

# Coder: ruinousdeity
# Version: 01
import os
import glob
import argparse
import pathlib
import unicodedata
import py7zr
import zipfile
import sys
from tqdm import tqdm

def logerror(message):
print("ERROR: "+message, file=sys.stderr, flush=True)

argParser = argparse.ArgumentParser(description='Check completeness of VAR files in a given directory')
argParser.add_argument("-p", "--path", type=pathlib.Path, default='.', help="path to VAR folder")

args = argParser.parse_args()

vars = glob.glob(str(args.path) + "/**/*.var", recursive = True)
invalid_files = []

for var in tqdm(vars, desc="Checking files"):
# Normalize the file path
var = os.path.normpath(var)
var = os.path.normcase(var)

try:
with zipfile.ZipFile(var) as myzip:
pass
except zipfile.BadZipFile:
try:
with py7zr.SevenZipFile(var, mode='r') as z:
pass
except py7zr.exceptions.Bad7zFile as e:
logerror(var+": not a 7z file")
invalid_files.append(var)
except Exception as e:
logerror(var+": "+str(e))
invalid_files.append(var)
except Exception as e:
logerror(var+": "+str(e))
invalid_files.append(var)

print(f'Total invalid .var files: {len(invalid_files)}')
for file in invalid_files:
print(file)
 
Back
Top Bottom