[[start:knowledge|<< Back]]\\ ====== Background ====== [[https://www.youtube.com/watch?v=Tr9E_vzKRVo|The History of Programming - [DevCon 2016]]]\\ [[https://nl.wikipedia.org/wiki/John_Backus#:~:text='software'%20ge%C3%AFntroduceerd.-,Backus%2DNaur%20Form,om%20algoritmen%20in%20te%20publiceren.|John Backus]]\\ ====== C++ ====== [[https://www.learncpp.com/|Learn CCP]] [[https://www.youtube.com/watch?v=GetaI7KhbzM|Mini Project: How to program a GPU? | CUDA C/C++]] ====== Lua ====== [[https://www.lua.org/|lua.org]] ====== Pyhon ====== ===== Usecases ===== ==== Copy all images from folder and child folders ==== import os import shutil def copy_images_and_parent_folder(source_folder, destination_folder): # Create the destination folder if it doesn't exist if not os.path.exists(destination_folder): os.makedirs(destination_folder) # Walk through the source folder and its subfolders for root, dirs, files in os.walk(source_folder): for file in files: # Check if the file is an image (based on file extension) if file.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp')): source_path = os.path.join(root, file) destination_path = os.path.join(destination_folder, file) shutil.copy2(source_path, destination_path) print(f"Copied {file} to {destination_folder}") # Copy the parent folder from the source to the destination parent_folder = os.path.dirname(source_folder) parent_folder_name = os.path.basename(parent_folder) destination_parent_folder = os.path.join(destination_folder, parent_folder_name) if not os.path.exists(destination_parent_folder): shutil.copytree(parent_folder, destination_parent_folder) print(f"Copied parent folder: {parent_folder_name}") # Set the source folder path (change to the desired folder) source_folder_path = "/path/to/your/source/folder" # Set the destination folder path (create a new folder or use an existing one) destination_folder_path = "/path/to/your/destination/folder" # Call the function to copy images and the parent folder copy_images_and_parent_folder(source_folder_path, destination_folder_path) }(); Replace "/path/to/your/source/folder" with the actual path to the folder containing your images, and "/path/to/your/destination/folder" with the desired destination folder. This script will copy image files source to the destination. ==== Delete all '.DS_Store' or/and 'thumbs.db' files ==== import os import tkinter as tk from tkinter import filedialog, messagebox, ttk def remove_files(folder_path, file_types): removed_count = {file_type: 0 for file_type in file_types} for root, dirs, files in os.walk(folder_path): for file in files: if file.lower() in file_types: file_path = os.path.join(root, file) try: os.remove(file_path) removed_count[file.lower()] += 1 except Exception as e: print(f"Error removing {file_path}: {e}") return removed_count def select_folder(): folder_path = filedialog.askdirectory() if folder_path: folder_var.set(folder_path) def clean_folder(): folder_path = folder_var.get() if not folder_path: messagebox.showerror("Error", "Please select a folder first.") return file_types = [] if ds_store_var.get(): file_types.append(".ds_store") if thumbs_db_var.get(): file_types.append("thumbs.db") if not file_types: messagebox.showerror("Error", "Please select at least one file type to clean.") return removed_count = remove_files(folder_path, file_types) message = "Cleanup Complete:\n" for file_type, count in removed_count.items(): message += f"Removed {count} {file_type} files\n" messagebox.showinfo("Cleanup Result", message) # Create the main window root = tk.Tk() root.title("Folder Cleaner") root.geometry("400x220") # Create and set up widgets folder_var = tk.StringVar() ds_store_var = tk.BooleanVar(value=True) thumbs_db_var = tk.BooleanVar(value=True) frame = ttk.Frame(root, padding="10") frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S)) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) ttk.Label(frame, text="Select a folder to clean:").grid(column=0, row=0, sticky=tk.W, pady=5) ttk.Entry(frame, textvariable=folder_var, width=50).grid(column=0, row=1, sticky=(tk.W, tk.E), pady=5) ttk.Button(frame, text="๐Ÿ“ Browse", command=select_folder).grid(column=1, row=1, sticky=tk.W, padx=5, pady=5) ttk.Label(frame, text="Select file types to clean:").grid(column=0, row=2, sticky=tk.W, pady=5) ttk.Checkbutton(frame, text=".DS_Store files", variable=ds_store_var).grid(column=0, row=3, sticky=tk.W) ttk.Checkbutton(frame, text="Thumbs.db files", variable=thumbs_db_var).grid(column=0, row=4, sticky=tk.W) ttk.Button(frame, text="๐Ÿงน Clean Folder", command=clean_folder).grid(column=0, row=5, sticky=tk.W, pady=10) # Start the GUI event loop root.mainloop()