import os,json def oshinoko(item): if "Oshi no Ko 2nd Season" in item: for x in item.split(): if x.isdigit() is True: number = int(x) number = number + 11 source = (f"D:/Jellyfin/Downloads/{item}") output = f"D:/Jellyfin/Anime/Oshi no Ko/Season 1/Oshi no Ko - {number}.mkv" os.link(source,output) with open("D:/Jellyfin/Downloads/check.txt","r+",encoding="utf-8") as outfile: file = json.load(outfile) k = os.listdir() if file != k: for x in k: if x not in file: try: oshinoko(x) finally: pass outfile.seek(0) outfile.truncate(0) json.dump(k,outfile)