-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmvfiles.ps1
38 lines (36 loc) · 1.38 KB
/
mvfiles.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
function mvfiles{
#write-host (Get-ChildItem $args[0]| Measure-Object ).Count;
$count1 = 0
$count2 = 0
$count3 = 0
If((Get-ChildItem $args[0]| Measure-Object ).Count -eq 0)
{
write-host "No files found for processing " -ForegroundColor "Red"
break
}
Foreach($file in (Get-ChildItem $args[0]))
{
#write-host $file.BaseName.Substring(0,1)
If($file.BaseName.Substring(0,1) -Match '^[a-l]')
{
$count1++
#write-host "Moving file $File to Destination 1 " -ForegroundColor "Green"
Move-Item -Path $($file.FullName) -Destination $args[1]
}
ElseIf($file.BaseName.Substring(0,1) -Match '^[m-z]')
{
$count2++
#write-host "Moving file $File to Destination 2 " -ForegroundColor "Yellow"
Move-Item -Path $($file.FullName) -Destination $args[2]
}
Else
{
$count3++
#write-host "Moving file $File to Trash" -ForegroundColor "Red"
Remove-Item -Path $($file.FullName)
}
}
# write-host "No of files moved to Destination 1: $count1" -ForegroundColor red -BackgroundColor white
# write-host "No of files moved to Destination 2: $count2" -ForegroundColor red -BackgroundColor white
# write-host "No of files deleted: $count3" -ForegroundColor red -BackgroundColor white
}