-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGet-Files.ps1
49 lines (49 loc) · 2.26 KB
/
Get-Files.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
49
<#
.SYNOPSIS
Get-Files
Created By: Dana Meli-Wischman
Created Date: August, 2018
Last Modified Date: September 22, 2021
.DESCRIPTION
This returns an output list of given files names in the given folder.
The list is formatted and sorted.
.EXAMPLE
Get-Files [-Folder] [<CompletePathToFolder>]\[<File spec like *.exe>]
.NOTES
Still under development.
#>
$Folder = "$args"
$FileVersion = "0.2.0"
$ESC = [char]27
if ($Folder -eq "DIR") {
$Folder = "."
Say "Get-Files $FileVersion Listing $Folder.ToUpper()"
Say ""
Try { Get-ChildItem -Path $Folder -Name -Directory | Sort-Object | ForEach-Object { Say $("$ESC[91m[$ESC[97m" + $_ + "$ESC[91m]") } }
Catch { Say ""; Say -ForegroundColor RED "Folder" $Folder.ToUpper() "was not found. Maybe add a '*'"; return }
Finally { Say "" }
Say ""
return
}
if ($Folder -eq "") { $Folder = "." }
Say "Get-Files $FileVersion Listing" $Folder.ToUpper()
try { Get-ChildItem -Path $Folder -Name -Directory -ErrorAction Stop | Sort-Object | ForEach-Object { Say $("$ESC[91m[$ESC[97m" + $_ + "$ESC[91m]") } }
Catch { Say ""; Say -ForegroundColor RED "Folder" $Folder.ToUpper() "was not found. Maybe add a '*'"; return }
Finally { Say "" }
Try {
Get-ChildItem -Path $Folder -Name -File -ErrorAction Stop | Sort-Object | ForEach-Object {
if ($_.substring(0, 1) -eq ".") { Say $("$ESC[92m" + $_) }
elseif ($_.split(".")[-1] -eq "TXT") { Say -ForeGroundColor Yellow $_ }
elseif ($_.split(".")[-1] -eq "INFO") { Say -ForeGroundColor Yellow $_ }
elseif ($_.split(".")[-1] -eq "CSS") { Say -ForeGroundColor Cyan $_ }
elseif ($_.split(".")[-1] -eq "PS1") { Say -ForeGroundColor RED $_ }
elseif ($_.split(".")[-1] -eq "MP3") { Say -ForeGroundColor BLUE $_ }
elseif ($_.split(".")[-1] -eq "EXE") { Say -ForeGroundColor WHITE $_ }
elseif ($_.split(".")[-1] -eq "JPG") { Say -ForeGroundColor Green $_ }
elseif ($_.split(".")[-1] -eq "PNG") { Say -ForeGroundColor Green $_ }
elseif ($_.split(".")[-1] -eq "ZIP") { Say -ForeGroundColor Magenta $_ }
else { Say $("$ESC[96m" + $_) }
}
}
Catch { Say ""; Say -ForegroundColor RED "Folder" $Folder.ToUpper() "was not found. Maybe add a '*'"; return }
Finally { Say "" }