From 209a08265ee520ef1e66bccd14c88cba3f2a9c8a49adec865b3a6de44daeb0b6 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 18 Sep 2026 10:47:31 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20dump-folders.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dump-folders.ps1 | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 dump-folders.ps1 diff --git a/dump-folders.ps1 b/dump-folders.ps1 new file mode 100644 index 0000000..6d3b887 --- /dev/null +++ b/dump-folders.ps1 @@ -0,0 +1,97 @@ +$sourcePath = "."; +$outputPath = "$sourcePath\ProjectDump.txt"; + +$excludeDirs = @(".git", ".vs", "bin", "obj", "packages", "TestResults"); +$excludeExts = @(".dll", ".exe", ".pdb", ".zip", ".png", ".jpg", ".jpeg", ".ico", ".suo", ".user", ".cache", ".slnx"); + +Function Get-ProjectTree { + param([string]$path, [string]$indent = "") + $output = ""; + + $allItems = Get-ChildItem -Path $path -ErrorAction SilentlyContinue; + $items = @(); + + for ($i = 0; $i -lt $allItems.Count; $i++) {$item = $allItems[$i]; + $isDir =$item.PSIsContainer; + + $skipItem =$false; + if ($isDir -and ($excludeDirs -contains $item.Name)) { + $skipItem =$true; + } + if (-not $isDir -and ($excludeExts -contains $item.Extension)) { + $skipItem =$true; + } + + if (-not $skipItem) { + $items +=$item; + } + } + + $count =$items.Count; + for ($j = 0; $j -lt $count; $j++) { + $item =$items[$j];$isLast = (($j + 1) -eq$count); + $marker = if ($isLast) { "└── " } else { "├── " }; + $output += "${indent}${marker}$($item.Name)`r`n"; + + if ($item.PSIsContainer) { + $newIndent = if ($isLast) { $indent + " " } else { $indent + "│ " }; + $output += Get-ProjectTree -path $item.FullName -indent$newIndent; + } + } + return $output; +} + +$rootPath = (Resolve-Path $sourcePath).Path; + +Set-Content -Path $outputPath -Value "=== ДЕРЕВО КАТАЛОГОВ ПРОЕКТА ===" -Encoding UTF8; + +$rootName = (Get-Item $rootPath).Name; +Add-Content -Path $outputPath -Value $rootName -Encoding UTF8; + +$tree = Get-ProjectTree -path $rootPath; +Add-Content -Path $outputPath -Value $tree -Encoding UTF8; + +Add-Content -Path $outputPath -Value "" -Encoding UTF8; +Add-Content -Path $outputPath -Value "=== ЛИСТИНГИ КОДА ===" -Encoding UTF8; + +$allFiles = Get-ChildItem -Path $rootPath -Recurse -File -ErrorAction SilentlyContinue; +$files = @(); +for ($f = 0; $f -lt $allFiles.Count; $f++) {$file = $allFiles[$f]; + if ($excludeExts -notcontains $file.Extension) { + $files +=$file; + } +} + +for ($k = 0; $k -lt $files.Count; $k++) {$file = $files[$k]; + $skip =$false; + + for ($d = 0; $d -lt $excludeDirs.Count; $d++) {$dir = $excludeDirs[$d]; + $dirPattern = "[\\/]$dir[\\/]"; + $checkPath = "\" + $file.FullName.Substring($rootPath.Length).Trim('\','/') + "\"; + if ($checkPath -match $dirPattern) { + $skip =$true; + break; + } + } + if ($skip) { continue; } + + $relPath = $file.FullName.Substring($rootPath.Length).TrimStart('\', '/'); + + Add-Content -Path $outputPath -Value "" -Encoding UTF8; + Add-Content -Path $outputPath -Value ("=" * 80) -Encoding UTF8; + Add-Content -Path $outputPath -Value "Файл: $($file.Name)" -Encoding UTF8; + Add-Content -Path $outputPath -Value "Относительный путь: $relPath" -Encoding UTF8; + Add-Content -Path $outputPath -Value ("=" * 80) -Encoding UTF8; + + try { + $content = Get-Content -Path $file.FullName -Encoding UTF8 -Raw -ErrorAction Stop; + if ($null -ne $content) { + Add-Content -Path $outputPath -Value $content -Encoding UTF8; + } + } + catch { + Add-Content -Path $outputPath -Value "[Пропущен: бинарный или нечитаемый файл]" -Encoding UTF8; + } +} + +Write-Host "Готово! Дамп сохранен в $outputPath"; \ No newline at end of file