Skip to content

Instantly share code, notes, and snippets.

View KK-Designs's full-sized avatar
💭
Probably Coding something... What else?

NotBacon KK-Designs

💭
Probably Coding something... What else?
View GitHub Profile
@KK-Designs
KK-Designs / getAllDllFilesInDirectoryAndThenReturnAllOfTheirPathsUsingForwardSlashesAndDirectoriesTwoLevelsUpAreReplacedByAPeriodInOneStringByJoiningThemTogetherByAnAsterisk.ps1
Created July 22, 2023 02:16
Get all dll files in a directory and then return all of their paths using forward slashes and directories two levels up are replaced by a period in one string by joining them together by an asterisk
# Get all DLL files in the specified directory and its subdirectories
$directory = "C:\your\directory\path"
$dllFiles = Get-ChildItem -Path $directory -Filter "*.dll" -File -Recurse
# Convert the paths to forward slashes and replace directories two levels up with a period
$paths = $dllFiles | ForEach-Object {
$relativePath = $_.FullName -replace '^(.*)\\(\w+)\\(\w+)\\(.+)$', '.\$3\$4'
$relativePath = $relativePath -replace "\\","/"
$relativePath
}