Skip to content

Instantly share code, notes, and snippets.

  • Save KK-Designs/5757a5dea2dd50b86c063ce1fbf55ced to your computer and use it in GitHub Desktop.
Save KK-Designs/5757a5dea2dd50b86c063ce1fbf55ced to your computer and use it in GitHub Desktop.
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
}
# Join the paths together using asterisk as the separator
$joinedPaths = $paths -join "*"
# Output the result
$joinedPaths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment