-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDelete-RawFile.ps1
48 lines (40 loc) · 1.38 KB
/
Delete-RawFile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<#
.SYNOPSIS
usun te rawy ktore nie maj jpg o tej samej nazwie
.DESCRIPTION
.EXAMPLE
.NOTES
autor: hajdus 2018
#>
# 1..10 | % { New-Item -Name "$_.raw" -ItemType file}
# 1..5 | % { New-Item -Name "$_.jpg" -ItemType file}
Write-Host -ForegroundColor Yellow "Wybiesz folder"
Add-Type -AssemblyName System.Windows.Forms
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$result = $FolderBrowser.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true }))
if ($result -eq [Windows.Forms.DialogResult]::OK) {
$Folder = $FolderBrowser.SelectedPath
}
else {
exit
}
$Obiekty = Get-ChildItem -Path $Folder
$count = 0
$ToNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) }
$raw = $Obiekty | ? {$_.Extension -eq ".raw"} | Sort-Object $ToNatural | select basename
$jpg = $Obiekty | ? {$_.Extension -eq ".jpg"} | Sort-Object $ToNatural | select basename
if (($raw -eq $null) -or ($jpg -eq $null)) {
Write-Host -ForegroundColor Red "BRAK PLIKOW Z ROZSZERZENIEM RAW LUB JPG"
Start-Sleep -s 2
exit
}
else {
$ToDel = Compare-Object $jpg $raw -Property basename
$ToDel | % {
$remove = $_.basename
Remove-Item "$Folder\$remove.raw" -WhatIf
$count++
}
Write-Host -ForegroundColor Green "Wszystkie pliki($count), z ktorych nie powstal‚ JPG zostaly usuniete. "
Start-Sleep -s 2
}