Missing files checkers:
nfo.py
Code: Select all
import os
def find_missing_nfo_files(folder):
missing_nfo_folders = []
for root, dirs, files in os.walk(folder):
if not any(file.lower().endswith('.nfo') for file in files):
missing_nfo_folders.append(root)
return missing_nfo_folders
def main():
folder = input("Enter the path of the folder to scan: ")
missing_nfo_folders = find_missing_nfo_files(folder)
if missing_nfo_folders:
print("Folders missing .nfo files:")
for folder in missing_nfo_folders:
print(folder)
else:
print("No folders are missing .nfo files.")
if __name__ == "__main__":
main()
Code: Select all
import os
def find_missing_m3u_files(folder):
missing_m3u_folders = []
for root, dirs, files in os.walk(folder):
if not any(file.lower().endswith('.m3u') for file in files):
missing_m3u_folders.append(root)
return missing_m3u_folders
def main():
folder = input("Enter the path of the folder to scan: ")
missing_m3u_folders = find_missing_m3u_files(folder)
if missing_m3u_folders:
print("Folders missing .m3u files:")
for folder in missing_m3u_folders:
print(folder)
else:
print("No folders are missing .m3u files.")
if __name__ == "__main__":
main()
Code: Select all
import os
def find_missing_sfv_files(folder):
missing_sfv_folders = []
for root, dirs, files in os.walk(folder):
if not any(file.lower().endswith('.sfv') for file in files):
missing_sfv_folders.append(root)
return missing_sfv_folders
def main():
folder = input("Enter the path of the folder to scan: ")
missing_sfv_folders = find_missing_sfv_files(folder)
if missing_sfv_folders:
print("Folders missing .sfv files:")
for folder in missing_sfv_folders:
print(folder)
else:
print("No folders are missing .sfv files.")
if __name__ == "__main__":
main()
mass_sfv_integrity.py
Code: Select all
import os
import sys
import zlib
from pathlib import Path
def crc(file_path):
prev = 0
if os.path.exists(file_path):
with open(file_path, "rb") as store:
for eachLine in store:
prev = zlib.crc32(eachLine, prev)
return "%x" % (prev & 0xFFFFFFFF)
else:
return None
def process_sfv_file(sfv_file_path):
with open(sfv_file_path) as sfv_file:
names_list = []
sfv_list = []
for line in sfv_file.readlines():
line = line.strip()
if line and not line.startswith(";"):
m = line.rsplit(' ', 1)
if len(m) == 2:
names_list.append(m[0])
sfv_list.append(m[1])
folder_has_bad_files = False
for i in range(len(names_list)):
file_path = os.path.join(os.path.dirname(sfv_file_path), names_list[i])
calc_sfv_value = crc(file_path)
if calc_sfv_value is None or sfv_list[i].lstrip('0').lower() != calc_sfv_value.lower():
folder_has_bad_files = True
break
if folder_has_bad_files:
print(f"\nFolder with bad files: {os.path.dirname(sfv_file_path)}")
def scan_folder(folder_path):
sfv_files = []
for root, _, files in os.walk(folder_path):
for file in files:
if file.endswith(".sfv"):
sfv_files.append(os.path.join(root, file))
total_sfv_files = len(sfv_files)
for index, sfv_file in enumerate(sfv_files, start=1):
process_sfv_file(sfv_file)
progress = (index / total_sfv_files) * 100
sys.stdout.write(f"\rProgress: {progress:.2f}%")
sys.stdout.flush()
if __name__ == "__main__":
folder = input("Enter the folder path: ")
if os.path.exists(folder):
scan_folder(folder)
else:
print("The folder does not exist.")
Enjoy!