ps/Modules/Alkami.DevOps.Operations/Retired/Get-RelativeFileList.ps1
2023-05-30 22:51:22 -07:00

30 lines
585 B
PowerShell

function Get-RelativeFileList {
<#
.SYNOPSIS
Returns a list of file names minus the base path.
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[string]$path = ".\",
[Parameter(Mandatory=$false)]
[string]$exclude = ""
)
$files = (Get-FilesNoSymlink $path)
# Trim the base path off.
$results = @()
$basePath = (Get-Item -path $path).FullName
$basePathSubstringLength = ($basePath.length + 1) # +1 gets leading slash.
$files | ForEach-Object {
if($_ -notlike $exclude)
{
$results += $_.substring($basePathSubstringLength)
}
}
return $results
}