groenklimaat opened issue #13897:
#!/usr/bin/env python3
"""
╔═══════════════════════════════════════════════════════════════════════════════╗
║ UNIVERSELE BESTANDSARCHIVER - Zonder Externe Packages ║
║ Werkt op Windows, Linux en macOS ZONDER extra installaties ║
╚═══════════════════════════════════════════════════════════════════════════════╝
"""import os
import shutil
import json
import threading
import time
import hashlib
import sys
import stat
from pathlib import Path
from datetime import datetime
from tkinter import *
from tkinter import ttk, filedialog, messagebox, scrolledtext
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Set, Any
from enum import Enum
from concurrent.futures import ThreadPoolExecutor, as_completed
import multiprocessing
import getpass
import platform============================================================================
PLATFORM DETECTIE
============================================================================
SYSTEM = platform.system()
IS_WINDOWS = SYSTEM == "Windows"
IS_LINUX = SYSTEM == "Linux"
IS_MAC = SYSTEM == "Darwin"============================================================================
CATEGORIEËN (Zonder externe packages)
============================================================================
class FileCategory(Enum):
DOCUMENTS = "Documenten"
SPREADSHEETS = "Spreadsheets"
PRESENTATIONS = "Presentaties"
PDF = "PDF"
TEXT = "Tekst"
IMAGES = "Afbeeldingen"
VIDEOS = "Video's"
AUDIO = "Muziek"
SOURCE_CODE = "Broncode"
SCRIPTS = "Scripts"
WEB = "Web"
DATABASES = "Databases"
CONFIG = "Configuratie"
SYSTEM = "Systeem"
TEMP = "Tijdelijk"
BACKUP = "Backups"
LOGS = "Logs"
ARCHIVES = "Archieven"
EXECUTABLES = "Uitvoerbaar"
INSTALLERS = "Installatie"
DOWNLOADS = "Downloads"
DESKTOP = "Bureaublad"
OTHER = "Overig"
UNKNOWN = "Onbekend"============================================================================
CONFIGURATIE
============================================================================
@dataclass
class ArchiveSettings:
source_folders: List[str] = field(default_factory=list)
archive_folder: str = ""
organize_by_category: bool = True
organize_by_date: bool = True
organize_by_type: bool = False
include_hidden: bool = False
include_system: bool = False
detect_duplicates: bool = True
duplicate_action: str = "skip"
use_multithreading: bool = True
max_workers: int = 4
delete_original: bool = True
dry_run: bool = False
max_depth: int = 20
max_size_mb: int = 10240============================================================================
BESTANDSANALYSATOR (Zonder externe packages)
============================================================================
class FileAnalyzer:
EXTENSION_CATEGORIES = {
# Documenten
'.doc': FileCategory.DOCUMENTS, '.docx': FileCategory.DOCUMENTS,
'.odt': FileCategory.DOCUMENTS, '.rtf': FileCategory.DOCUMENTS,
'.xls': FileCategory.SPREADSHEETS, '.xlsx': FileCategory.SPREADSHEETS,
'.ods': FileCategory.SPREADSHEETS, '.csv': FileCategory.SPREADSHEETS,
'.ppt': FileCategory.PRESENTATIONS, '.pptx': FileCategory.PRESENTATIONS,
'.odp': FileCategory.PRESENTATIONS,
'.pdf': FileCategory.PDF,
'.txt': FileCategory.TEXT, '.md': FileCategory.TEXT,
# Afbeeldingen
'.jpg': FileCategory.IMAGES, '.jpeg': FileCategory.IMAGES,
'.png': FileCategory.IMAGES, '.gif': FileCategory.IMAGES,
'.bmp': FileCategory.IMAGES, '.tiff': FileCategory.IMAGES,
'.svg': FileCategory.IMAGES, '.ico': FileCategory.IMAGES,
'.webp': FileCategory.IMAGES, '.psd': FileCategory.IMAGES,
# Video
'.mp4': FileCategory.VIDEOS, '.avi': FileCategory.VIDEOS,
'.mkv': FileCategory.VIDEOS, '.mov': FileCategory.VIDEOS,
'.wmv': FileCategory.VIDEOS, '.flv': FileCategory.VIDEOS,
'.webm': FileCategory.VIDEOS, '.m4v': FileCategory.VIDEOS,
'.mpg': FileCategory.VIDEOS, '.mpeg': FileCategory.VIDEOS,
# Audio
'.mp3': FileCategory.AUDIO, '.wav': FileCategory.AUDIO,
'.flac': FileCategory.AUDIO, '.aac': FileCategory.AUDIO,
'.ogg': FileCategory.AUDIO, '.wma': FileCategory.AUDIO,
'.m4a': FileCategory.AUDIO, '.aiff': FileCategory.AUDIO,
# Code
'.py': FileCategory.SOURCE_CODE, '.pyw': FileCategory.SOURCE_CODE,
'.java': FileCategory.SOURCE_CODE, '.c': FileCategory.SOURCE_CODE,
'.cpp': FileCategory.SOURCE_CODE, '.h': FileCategory.SOURCE_CODE,
'.cs': FileCategory.SOURCE_CODE, '.vb': FileCategory.SOURCE_CODE,
'.go': FileCategory.SOURCE_CODE, '.rs': FileCategory.SOURCE_CODE,
'.swift': FileCategory.SOURCE_CODE, '.kt': FileCategory.SOURCE_CODE,
# Scripts
'.sh': FileCategory.SCRIPTS, '.bash': FileCategory.SCRIPTS,
'.ps1': FileCategory.SCRIPTS, '.vbs': FileCategory.SCRIPTS,
'.bat': FileCategory.SCRIPTS, '.cmd': FileCategory.SCRIPTS,
'.js': FileCategory.SCRIPTS, '.ts': FileCategory.SCRIPTS,
'.rb': FileCategory.SCRIPTS, '.pl': FileCategory.SCRIPTS,
# Web
'.html': FileCategory.WEB, '.htm': FileCategory.WEB,
'.css': FileCategory.WEB, '.scss': FileCategory.WEB,
'.php': FileCategory.WEB, '.asp': FileCategory.WEB,
'.jsp': FileCategory.WEB, '.xml': FileCategory.WEB,
'.json': FileCategory.WEB, '.yaml': FileCategory.WEB,
'.yml': FileCategory.WEB, '.toml': FileCategory.WEB,
# Databases
'.sql': FileCategory.DATABASES, '.db': FileCategory.DATABASES,
'.sqlite': FileCategory.DATABASES, '.sqlite3': FileCategory.DATABASES,
'.mdb': FileCategory.DATABASES, '.accdb': FileCategory.DATABASES,
# Configuratie
'.cfg': FileCategory.CONFIG, '.conf': FileCategory.CONFIG,
'.ini': FileCategory.CONFIG, '.env': FileCategory.CONFIG,
# Logs
'.log': FileCategory.LOGS, '.out': FileCategory.LOGS,
# Archieven
'.zip': FileCategory.ARCHIVES, '.rar': FileCategory.ARCHIVES,
'.7z': FileCategory.ARCHIVES, '.tar': FileCategory.ARCHIVES,
'.gz': FileCategory.ARCHIVES, '.bz2': FileCategory.ARCHIVES,
'.xz': FileCategory.ARCHIVES, '.tgz': FileCategory.ARCHIVES,
# Uitvoerbaar
'.exe': FileCategory.EXECUTABLES, '.msi': FileCategory.INSTALLERS,
'.dmg': FileCategory.INSTALLERS, '.pkg': FileCategory.INSTALLERS,
'.deb': FileCategory.INSTALLERS, '.rpm': FileCategory.INSTALLERS,
'.app': FileCategory.EXECUTABLES, '.AppImage': FileCategory.EXECUTABLES,
}def analyze_file(self, filepath: Path) -> Optional[Dict[str, Any]]: try: if not filepath.exists(): return None stat_info = filepath.stat() size_bytes = stat_info.st_size name = filepath.name extension = filepath.suffix.lower() # Bepaal categorie op basis van pad category = self._determine_category(filepath, extension) # Bepaal of het verborgen is is_hidden = name.startswith('.') if IS_WINDOWS: try: # Simpele check voor Windows verborgen bestanden if os.path.exists(str(filepath)): # Gebruik attributen via command line of simpele check pass except: pass # Bepaal of het een systeembestand is is_system = self._is_system_file(filepath) # Bereken checksum voor kleine bestanden checksum = None if size_bytes < 50 * 1024 * 1024: # 50MB checksum = self._calculate_md5(filepath) return { 'path': filepath, 'name': name, 'extension': extension, 'size_bytes': size_bytes, 'size_mb': size_bytes / (1024 * 1024), 'category': category, 'is_hidden': is_hidden, 'is_system': is_system, 'checksum': checksum, 'modified': datetime.fromtimestamp(stat_info.st_mtime), 'created': datetime.fromtimestamp(stat_info.st_ctime), 'parent': filepath.parent.name } except Exception: return None def _determine_category(self, filepath: Path, extension: str) -> FileCategory: path_str = str(filepath).lower() name = filepath.name.lower() # Pad patronen path_patterns = { FileCategory.DOCUMENTS: ['/documents', '/documenten', '/docs'], FileCategory.IMAGES: ['/images', '/afbeeldingen', '/pictures', '/photos'], FileCategory.VIDEOS: ['/videos', '/video', '/movies', '/films'], FileCategory.AUDIO: ['/music', '/muziek', '/audio', '/songs'], FileCategory.SOURCE_CODE: ['/src', '/source', '/code', '/development'], FileCategory.DATABASES: ['/databases', '/db', '/sql'], FileCategory.CONFIG: ['/config', '/configuration', '/settings'], FileCategory.LOGS: ['/logs', '/log'], FileCategory.BACKUP: ['/backup', '/back-ups', '/backups'], FileCategory.TEMP: ['/temp', '/tmp', '/cache'], FileCategory.DOWNLOADS: ['/downloads', '/download'], FileCategory.DESKTOP: ['/desktop', '/bureaublad'], } for category, patterns in path_patterns.items(): for pattern in patterns: if pattern in path_str: return category[message truncated]
alexcrichton closed issue #13897:
#!/usr/bin/env python3
"""
╔═══════════════════════════════════════════════════════════════════════════════╗
║ UNIVERSELE BESTANDSARCHIVER - Zonder Externe Packages ║
║ Werkt op Windows, Linux en macOS ZONDER extra installaties ║
╚═══════════════════════════════════════════════════════════════════════════════╝
"""import os
import shutil
import json
import threading
import time
import hashlib
import sys
import stat
from pathlib import Path
from datetime import datetime
from tkinter import *
from tkinter import ttk, filedialog, messagebox, scrolledtext
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Set, Any
from enum import Enum
from concurrent.futures import ThreadPoolExecutor, as_completed
import multiprocessing
import getpass
import platform============================================================================
PLATFORM DETECTIE
============================================================================
SYSTEM = platform.system()
IS_WINDOWS = SYSTEM == "Windows"
IS_LINUX = SYSTEM == "Linux"
IS_MAC = SYSTEM == "Darwin"============================================================================
CATEGORIEËN (Zonder externe packages)
============================================================================
class FileCategory(Enum):
DOCUMENTS = "Documenten"
SPREADSHEETS = "Spreadsheets"
PRESENTATIONS = "Presentaties"
PDF = "PDF"
TEXT = "Tekst"
IMAGES = "Afbeeldingen"
VIDEOS = "Video's"
AUDIO = "Muziek"
SOURCE_CODE = "Broncode"
SCRIPTS = "Scripts"
WEB = "Web"
DATABASES = "Databases"
CONFIG = "Configuratie"
SYSTEM = "Systeem"
TEMP = "Tijdelijk"
BACKUP = "Backups"
LOGS = "Logs"
ARCHIVES = "Archieven"
EXECUTABLES = "Uitvoerbaar"
INSTALLERS = "Installatie"
DOWNLOADS = "Downloads"
DESKTOP = "Bureaublad"
OTHER = "Overig"
UNKNOWN = "Onbekend"============================================================================
CONFIGURATIE
============================================================================
@dataclass
class ArchiveSettings:
source_folders: List[str] = field(default_factory=list)
archive_folder: str = ""
organize_by_category: bool = True
organize_by_date: bool = True
organize_by_type: bool = False
include_hidden: bool = False
include_system: bool = False
detect_duplicates: bool = True
duplicate_action: str = "skip"
use_multithreading: bool = True
max_workers: int = 4
delete_original: bool = True
dry_run: bool = False
max_depth: int = 20
max_size_mb: int = 10240============================================================================
BESTANDSANALYSATOR (Zonder externe packages)
============================================================================
class FileAnalyzer:
EXTENSION_CATEGORIES = {
# Documenten
'.doc': FileCategory.DOCUMENTS, '.docx': FileCategory.DOCUMENTS,
'.odt': FileCategory.DOCUMENTS, '.rtf': FileCategory.DOCUMENTS,
'.xls': FileCategory.SPREADSHEETS, '.xlsx': FileCategory.SPREADSHEETS,
'.ods': FileCategory.SPREADSHEETS, '.csv': FileCategory.SPREADSHEETS,
'.ppt': FileCategory.PRESENTATIONS, '.pptx': FileCategory.PRESENTATIONS,
'.odp': FileCategory.PRESENTATIONS,
'.pdf': FileCategory.PDF,
'.txt': FileCategory.TEXT, '.md': FileCategory.TEXT,
# Afbeeldingen
'.jpg': FileCategory.IMAGES, '.jpeg': FileCategory.IMAGES,
'.png': FileCategory.IMAGES, '.gif': FileCategory.IMAGES,
'.bmp': FileCategory.IMAGES, '.tiff': FileCategory.IMAGES,
'.svg': FileCategory.IMAGES, '.ico': FileCategory.IMAGES,
'.webp': FileCategory.IMAGES, '.psd': FileCategory.IMAGES,
# Video
'.mp4': FileCategory.VIDEOS, '.avi': FileCategory.VIDEOS,
'.mkv': FileCategory.VIDEOS, '.mov': FileCategory.VIDEOS,
'.wmv': FileCategory.VIDEOS, '.flv': FileCategory.VIDEOS,
'.webm': FileCategory.VIDEOS, '.m4v': FileCategory.VIDEOS,
'.mpg': FileCategory.VIDEOS, '.mpeg': FileCategory.VIDEOS,
# Audio
'.mp3': FileCategory.AUDIO, '.wav': FileCategory.AUDIO,
'.flac': FileCategory.AUDIO, '.aac': FileCategory.AUDIO,
'.ogg': FileCategory.AUDIO, '.wma': FileCategory.AUDIO,
'.m4a': FileCategory.AUDIO, '.aiff': FileCategory.AUDIO,
# Code
'.py': FileCategory.SOURCE_CODE, '.pyw': FileCategory.SOURCE_CODE,
'.java': FileCategory.SOURCE_CODE, '.c': FileCategory.SOURCE_CODE,
'.cpp': FileCategory.SOURCE_CODE, '.h': FileCategory.SOURCE_CODE,
'.cs': FileCategory.SOURCE_CODE, '.vb': FileCategory.SOURCE_CODE,
'.go': FileCategory.SOURCE_CODE, '.rs': FileCategory.SOURCE_CODE,
'.swift': FileCategory.SOURCE_CODE, '.kt': FileCategory.SOURCE_CODE,
# Scripts
'.sh': FileCategory.SCRIPTS, '.bash': FileCategory.SCRIPTS,
'.ps1': FileCategory.SCRIPTS, '.vbs': FileCategory.SCRIPTS,
'.bat': FileCategory.SCRIPTS, '.cmd': FileCategory.SCRIPTS,
'.js': FileCategory.SCRIPTS, '.ts': FileCategory.SCRIPTS,
'.rb': FileCategory.SCRIPTS, '.pl': FileCategory.SCRIPTS,
# Web
'.html': FileCategory.WEB, '.htm': FileCategory.WEB,
'.css': FileCategory.WEB, '.scss': FileCategory.WEB,
'.php': FileCategory.WEB, '.asp': FileCategory.WEB,
'.jsp': FileCategory.WEB, '.xml': FileCategory.WEB,
'.json': FileCategory.WEB, '.yaml': FileCategory.WEB,
'.yml': FileCategory.WEB, '.toml': FileCategory.WEB,
# Databases
'.sql': FileCategory.DATABASES, '.db': FileCategory.DATABASES,
'.sqlite': FileCategory.DATABASES, '.sqlite3': FileCategory.DATABASES,
'.mdb': FileCategory.DATABASES, '.accdb': FileCategory.DATABASES,
# Configuratie
'.cfg': FileCategory.CONFIG, '.conf': FileCategory.CONFIG,
'.ini': FileCategory.CONFIG, '.env': FileCategory.CONFIG,
# Logs
'.log': FileCategory.LOGS, '.out': FileCategory.LOGS,
# Archieven
'.zip': FileCategory.ARCHIVES, '.rar': FileCategory.ARCHIVES,
'.7z': FileCategory.ARCHIVES, '.tar': FileCategory.ARCHIVES,
'.gz': FileCategory.ARCHIVES, '.bz2': FileCategory.ARCHIVES,
'.xz': FileCategory.ARCHIVES, '.tgz': FileCategory.ARCHIVES,
# Uitvoerbaar
'.exe': FileCategory.EXECUTABLES, '.msi': FileCategory.INSTALLERS,
'.dmg': FileCategory.INSTALLERS, '.pkg': FileCategory.INSTALLERS,
'.deb': FileCategory.INSTALLERS, '.rpm': FileCategory.INSTALLERS,
'.app': FileCategory.EXECUTABLES, '.AppImage': FileCategory.EXECUTABLES,
}def analyze_file(self, filepath: Path) -> Optional[Dict[str, Any]]: try: if not filepath.exists(): return None stat_info = filepath.stat() size_bytes = stat_info.st_size name = filepath.name extension = filepath.suffix.lower() # Bepaal categorie op basis van pad category = self._determine_category(filepath, extension) # Bepaal of het verborgen is is_hidden = name.startswith('.') if IS_WINDOWS: try: # Simpele check voor Windows verborgen bestanden if os.path.exists(str(filepath)): # Gebruik attributen via command line of simpele check pass except: pass # Bepaal of het een systeembestand is is_system = self._is_system_file(filepath) # Bereken checksum voor kleine bestanden checksum = None if size_bytes < 50 * 1024 * 1024: # 50MB checksum = self._calculate_md5(filepath) return { 'path': filepath, 'name': name, 'extension': extension, 'size_bytes': size_bytes, 'size_mb': size_bytes / (1024 * 1024), 'category': category, 'is_hidden': is_hidden, 'is_system': is_system, 'checksum': checksum, 'modified': datetime.fromtimestamp(stat_info.st_mtime), 'created': datetime.fromtimestamp(stat_info.st_ctime), 'parent': filepath.parent.name } except Exception: return None def _determine_category(self, filepath: Path, extension: str) -> FileCategory: path_str = str(filepath).lower() name = filepath.name.lower() # Pad patronen path_patterns = { FileCategory.DOCUMENTS: ['/documents', '/documenten', '/docs'], FileCategory.IMAGES: ['/images', '/afbeeldingen', '/pictures', '/photos'], FileCategory.VIDEOS: ['/videos', '/video', '/movies', '/films'], FileCategory.AUDIO: ['/music', '/muziek', '/audio', '/songs'], FileCategory.SOURCE_CODE: ['/src', '/source', '/code', '/development'], FileCategory.DATABASES: ['/databases', '/db', '/sql'], FileCategory.CONFIG: ['/config', '/configuration', '/settings'], FileCategory.LOGS: ['/logs', '/log'], FileCategory.BACKUP: ['/backup', '/back-ups', '/backups'], FileCategory.TEMP: ['/temp', '/tmp', '/cache'], FileCategory.DOWNLOADS: ['/downloads', '/download'], FileCategory.DESKTOP: ['/desktop', '/bureaublad'], } for category, patterns in path_patterns.items(): for pattern in patterns: if pattern in path_str: return category[message truncated]
alexcrichton edited issue #13897:
deleted
Last updated: Jul 29 2026 at 05:03 UTC