import os from shutil import copyfile print('---begin of the script---') demo_path = os.path.join(os.getenv('APPDATA'), "Teeworlds\\demos\\auto") demo_dest_path = "D:\\Games\\teeworlds\\demos_check" demos_already_in_dest_path = [file for file in os.listdir(demo_dest_path) if file.endswith(".demo")] print 'from: ' + demo_path print 'to: ' + demo_dest_path demo_files = [file for file in os.listdir(demo_path) if file.endswith(".demo")] for demo_file in demo_files: if demo_file in demos_already_in_dest_path: continue demo_file_path = os.path.join(demo_path, demo_file) with open(demo_file_path, "rb") as f: f.seek(178) byte = f.read(2).encode("hex") markers_num = int('0x' + byte, 0) if markers_num > 0: print demo_file copyfile(demo_file_path, os.path.join(demo_dest_path, demo_file)) print('---end of the script---')