diff --git a/organize_erecept.ps1 b/organize_erecept.ps1 new file mode 100644 index 0000000..61b1c31 --- /dev/null +++ b/organize_erecept.ps1 @@ -0,0 +1,31 @@ +# Organizace eRecept dokumentace do podsložek podle data +$sourceDir = "U:\Dropbox\!!!Days\Downloads Z230\eRecept" + +Get-ChildItem -Path $sourceDir -File | ForEach-Object { + $file = $_ + # Vyber datum ze začátku názvu souboru (formát YYYY-MM-DD) + if ($file.Name -match "^(\d{4}-\d{2}-\d{2})") { + $date = $matches[1] + $targetDir = Join-Path $sourceDir $date + + # Vytvoř složku pokud neexistuje + if (-not (Test-Path $targetDir)) { + New-Item -ItemType Directory -Path $targetDir | Out-Null + Write-Host "Vytvořena složka: $date" + } + + # ZIP soubory rozbal, ostatní přesuň + if ($file.Extension -eq ".zip") { + Write-Host "Rozbaluji: $($file.Name) -> $date\" + Expand-Archive -Path $file.FullName -DestinationPath $targetDir -Force + Remove-Item $file.FullName + } else { + Write-Host "Přesouvám: $($file.Name) -> $date\" + Move-Item -Path $file.FullName -Destination $targetDir -Force + } + } else { + Write-Host "Přeskakuji (bez data): $($file.Name)" + } +} + +Write-Host "`nHotovo!"