software / HIDEFILE.py
shethjenil's picture
Rename hide.py to HIDEFILE.py
d0f2db0 verified
raw
history blame
1.08 kB
from tkinter.filedialog import askopenfilename , asksaveasfilename , askdirectory
from tkinter.messagebox import showinfo
from zipfile import ZipFile
from os import walk , path
from io import BytesIO
def get_all_file_paths(directory):
file_paths = []
for root, directories, files in walk(directory):
for filename in files:
file_paths.append(path.join(root, filename))
return file_paths
def folder_to_zip_file_bytes(folder_path):
zip_file_bytes = BytesIO()
with ZipFile(zip_file_bytes, "w") as zip_file:
for file_path in get_all_file_paths(folder_path):
zip_file.write(file_path, file_path.split("/")[-1])
return zip_file_bytes.getvalue()
def combine_files(main:str, bindfolder:str):
extension = main.split(".")[-1]
open(asksaveasfilename(filetypes=[("HIDDEN FILE",[f"*.{extension}"])],initialfile=f"hidden.{extension}"), 'wb').write(open(main, 'rb').read()+folder_to_zip_file_bytes(bindfolder))
showinfo("HIDDEN FILE","You can use this tool to hide folders inside a file.")
combine_files(askopenfilename(),askdirectory())