-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader Eraser.py
More file actions
57 lines (47 loc) · 2.19 KB
/
Header Eraser.py
File metadata and controls
57 lines (47 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import tkinter as tk
from tkinter import filedialog, messagebox
import datetime
def select_directory():
global directory
directory = filedialog.askdirectory()
def read_files():
try:
log_text.delete("1.0", "end")
log_file_path = os.path.join(directory, "logs", "UnityFS_Log.txt")
os.makedirs(os.path.dirname(log_file_path), exist_ok=True)
with open(log_file_path, "w") as log_file:
log_file.write(f"{datetime.datetime.now()}\n")
for file in os.listdir(directory):
f = os.path.join(directory, file)
if os.path.isfile(f):
with open(f, 'rb') as f:
b = f.read()
i = 0
while i < len(b):
if b[i:i+7] == b'UnityFS':
c = b[i:]
break
i += 1
if i == len(b):
log_text.insert("end", f"UnityFS not found in file {file}\n")
log_file.write(f"{file},UnityFS not found\n")
else:
output_file_path = os.path.join(directory, "Read", file+'.read')
os.makedirs(os.path.dirname(output_file_path), exist_ok=True)
with open(output_file_path, "wb") as output_file:
output_file.write(c)
log_text.insert("end", f"{file} read successfully\n")
log_file.write(f"{file},Success\n")
messagebox.showinfo("Success", "All files have been processed successfully!")
except Exception as e:
messagebox.showerror("Error", str(e))
window = tk.Tk()
window.title("UnityFS Reader")
select_dir_button = tk.Button(window, text="Select Directory", command=select_directory)
select_dir_button.pack(pady=10)
read_files_button = tk.Button(window, text="Read Files", command=read_files)
read_files_button.pack(pady=10)
log_text = tk.Text(window, height=10, width=50)
log_text.pack(pady=10)
window.mainloop()