diff --git a/README.md b/README.md index ca8f886..437e021 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ `.jpg` `.jpeg` `.png` `.heic` `.tiff` `.tif` `.webp` `.bmp` `.cr2` `.cr3` `.nef` `.arw` `.dng` (Raw) -`.avi` +`.avi` `.mp4` ## Установка @@ -33,6 +33,9 @@ python organize.py "D:\Фото\Скопировать" # Только посмотреть, что будет (ничего не перемещает) python organize.py --dry-run +# Обработать только первые 10 файлов +python organize.py --max-files 10 + # Без цвета (для пайпов) python organize.py --no-color @@ -43,6 +46,16 @@ python organize.py --quiet python organize.py --group-by month ``` +## Лимит файлов + +По умолчанию обрабатывается **до 10 000 файлов** за запуск. + +Где менять: +1. Открой `organize.py` любым текстовым редактором +2. Найди **`MAX_FILES = 10000`** (строка ~69, после `EXTENSIONS`) +3. Поменяй число на нужное (например `MAX_FILES = 100`) +4. Сохрани — готово + ## Логи После каждого запуска создаются: @@ -59,7 +72,7 @@ install.bat uninstall-context-menu.bat ``` -После установки: -- **ПКМ в пустом месте папки** → «Raskidator-3000» — обработает текущую папку -- **ПКМ на папке** → «Raskidator-3000» — обработает выбранную папку +После установки в контекстном меню два пункта: +- **«Raskidator-3000»** — сортировка (реальное перемещение) +- **«Raskidator-3000 (dry-run)»** — только показать что будет перемещено - **Работает в библиотеках** (Pictures, Music, Videos, Documents) diff --git a/install.bat b/install.bat index 5c093f2..1cd033a 100644 --- a/install.bat +++ b/install.bat @@ -1,5 +1,6 @@ @echo off -title Raskidator-3000 - Install context menu +chcp 65001 >nul +title Raskidator-3000 — Install context menu echo ======================================== echo Install context menu @@ -11,30 +12,52 @@ echo. :: Directory\Background\shell - right-click in empty folder space echo [1/3] Adding to folder background context menu... + +:: Обычный запуск reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000" /ve /t REG_SZ /d "Raskidator-3000" /f reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000" /v Icon /t REG_SZ /d "%~dp0raskidator.bat,0" /f reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000\command" /ve /t REG_SZ /d "\"%~dp0raskidator.bat\" \"%%V\"" /f -echo [+] Directory\Background - done + +:: Пробный запуск (dry-run) +reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000DryRun" /ve /t REG_SZ /d "Raskidator-3000 (dry-run)" /f +reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000DryRun" /v Icon /t REG_SZ /d "%~dp0raskidator.bat,0" /f +reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000DryRun\command" /ve /t REG_SZ /d "\"%~dp0raskidator.bat\" --dry-run \"%%V\"" /f + +echo [+] Directory\Background - done (2 entries) echo. :: Directory\shell - right-click on folder echo [2/3] Adding to folder right-click menu... + reg add "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000" /ve /t REG_SZ /d "Raskidator-3000" /f reg add "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000" /v Icon /t REG_SZ /d "%~dp0raskidator.bat,0" /f reg add "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000\command" /ve /t REG_SZ /d "\"%~dp0raskidator.bat\" \"%%1\"" /f -echo [+] Directory\shell - done + +reg add "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000DryRun" /ve /t REG_SZ /d "Raskidator-3000 (dry-run)" /f +reg add "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000DryRun" /v Icon /t REG_SZ /d "%~dp0raskidator.bat,0" /f +reg add "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000DryRun\command" /ve /t REG_SZ /d "\"%~dp0raskidator.bat\" --dry-run \"%%1\"" /f + +echo [+] Directory\shell - done (2 entries) echo. :: LibraryFolder\Background - Pictures, Music, Videos... echo [3/3] Adding to libraries (Pictures, Music, Videos)... + reg add "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000" /ve /t REG_SZ /d "Raskidator-3000" /f reg add "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000" /v Icon /t REG_SZ /d "%~dp0raskidator.bat,0" /f reg add "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000\command" /ve /t REG_SZ /d "\"%~dp0raskidator.bat\" \"%%V\"" /f -echo [+] LibraryFolder\Background - done + +reg add "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000DryRun" /ve /t REG_SZ /d "Raskidator-3000 (dry-run)" /f +reg add "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000DryRun" /v Icon /t REG_SZ /d "%~dp0raskidator.bat,0" /f +reg add "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000DryRun\command" /ve /t REG_SZ /d "\"%~dp0raskidator.bat\" --dry-run \"%%V\"" /f + +echo [+] LibraryFolder\Background - done (2 entries) echo. echo ======================================== echo Installation complete! -echo Right-click any folder -> Raskidator-3000 +echo Right-click any folder -> +echo Raskidator-3000 — сортировка +echo Raskidator-3000 (dry-run) — пробный запуск echo ======================================== pause diff --git a/organize.py b/organize.py index 7dccef0..8883d77 100644 --- a/organize.py +++ b/organize.py @@ -67,6 +67,8 @@ EXTENSIONS = { '.mp4', } +MAX_FILES = 10000 # ← меняй тут: сколько файлов обрабатывать за один запуск + # ANSI colour codes _GREEN = '\033[32m' _YELLOW = '\033[33m' @@ -314,6 +316,7 @@ def organize( no_color: bool = False, group_by: str = 'day', quiet: bool = False, + max_files: int | None = None, ) -> int: """Scan *folder* and sort images into year/month[/day] subfolders. @@ -329,6 +332,11 @@ def organize( if f.is_file() and f.suffix.lower() in EXTENSIONS ] files.sort() + if max_files is not None and len(files) > max_files: + print(_c(f' First {max_files} of {len(files)} files ' + f'(edit MAX_FILES in organize.py to change)', + _CYAN, no_color=no_color)) + files = files[:max_files] if not files: print(_c(' No supported files found.', _YELLOW, no_color=no_color)) @@ -647,14 +655,24 @@ def main() -> None: default='day', help='Output folder granularity: year/month/day (default) or year/month', ) + parser.add_argument( + '--max-files', + type=int, + default=None, + help=f'Max files to process per run (default: {MAX_FILES}, but use MAX_FILES constant at top of organize.py)', + ) args = parser.parse_args() + # If --max-files not set, use MAX_FILES constant + max_files = args.max_files if args.max_files is not None else MAX_FILES folder = Path(args.path) if args.path else Path.cwd() print(_c('Raskidator-3000', _BOLD, no_color=args.no_color)) print(f' Folder: {folder.resolve()}') if args.dry_run: print(_c(' Mode: DRY-RUN', _CYAN, no_color=args.no_color)) + if max_files: + print(f' Max files: {max_files}') print() rc = organize( @@ -663,6 +681,7 @@ def main() -> None: no_color=args.no_color, group_by=args.group_by, quiet=args.quiet, + max_files=max_files, ) sys.exit(rc) diff --git a/raskidator.bat b/raskidator.bat index 9049d49..a65f7a8 100644 --- a/raskidator.bat +++ b/raskidator.bat @@ -7,6 +7,13 @@ echo Raskidator-3000 — сортировка фотографий echo ======================================== echo. +:: Определяем режим (--dry-run или обычный) +set "DRY=" +if /i "%~1"=="--dry-run" ( + set "DRY=--dry-run" + shift +) + :: Определяем папку, которую обрабатываем if "%~1"=="" ( set "TARGET=%CD%" @@ -15,6 +22,7 @@ if "%~1"=="" ( ) echo Папка: %TARGET% +if not "%DRY%"=="" echo Режим: ПРОБНЫЙ (dry-run) echo. :: Проверяем, существует ли скрипт @@ -26,11 +34,11 @@ if not exist "%SCRIPT%" ( ) :: Пробуем python (наиболее распространён) -python "%SCRIPT%" "%TARGET%" +python "%SCRIPT%" %DRY% "%TARGET%" if %errorlevel% equ 0 goto :end :: Если python не сработал — пробуем py -3 (Python Launcher) -py -3 "%SCRIPT%" "%TARGET%" +py -3 "%SCRIPT%" %DRY% "%TARGET%" if %errorlevel% equ 0 goto :end :: Если оба не сработали diff --git a/uninstall-context-menu.bat b/uninstall-context-menu.bat index 288e53d..e006acb 100644 --- a/uninstall-context-menu.bat +++ b/uninstall-context-menu.bat @@ -1,5 +1,6 @@ @echo off -title Raskidator-3000 - Uninstall context menu +chcp 65001 >nul +title Raskidator-3000 — Uninstall context menu echo ======================================== echo Uninstall context menu @@ -9,17 +10,20 @@ echo. echo [1/3] Removing from folder background context menu... reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000" /f >nul 2>&1 -if %errorlevel% equ 0 (echo [+] Directory\Background - removed) else (echo [-] Directory\Background - not found) +reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\Raskidator3000DryRun" /f >nul 2>&1 +if %errorlevel% equ 0 (echo [+] Directory\Background - removed) else (echo [+] Directory\Background - done) echo. echo [2/3] Removing from folder right-click menu... reg delete "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000" /f >nul 2>&1 -if %errorlevel% equ 0 (echo [+] Directory\shell - removed) else (echo [-] Directory\shell - not found) +reg delete "HKEY_CLASSES_ROOT\Directory\shell\Raskidator3000DryRun" /f >nul 2>&1 +if %errorlevel% equ 0 (echo [+] Directory\shell - removed) else (echo [+] Directory\shell - done) echo. echo [3/3] Removing from libraries (Pictures, Music, Videos)... reg delete "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000" /f >nul 2>&1 -if %errorlevel% equ 0 (echo [+] LibraryFolder\Background - removed) else (echo [-] LibraryFolder\Background - not found) +reg delete "HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Raskidator3000DryRun" /f >nul 2>&1 +if %errorlevel% equ 0 (echo [+] LibraryFolder\Background - removed) else (echo [+] LibraryFolder\Background - done) echo. echo ========================================