Skip to content

Instantly share code, notes, and snippets.

@thorade
Last active March 15, 2016 11:13
Show Gist options
  • Save thorade/e4dec248c95d49d40fcd to your computer and use it in GitHub Desktop.
Save thorade/e4dec248c95d49d40fcd to your computer and use it in GitHub Desktop.
PowerShell script that recursively scans a given directory and prints a list of all file extenions
# This PowerShell Script will recursively scan all files in the given $scanDir
# and print a list of all file extensions it finds
#
# get current directory
$curPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$curDir = Split-Path -Leaf -Path $curPath
$scanDir = "BuildingSystems"
$scanPath = $curPath + "\" + $scanDir
$outFile = $scanPath + "\fileExtensions.txt"
# print the list of file extensions
Get-ChildItem $scanPath -recurse | Select-Object Extension | Sort-Object Extension | Get-Unique -asString | Out-File $outFile
#Read-Host "Press Enter to close"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment