Skip to content

August 4, 2009


Export List of File Names with PowerShell

Here’s a quick and easy little function to get a list of files (and their paths) using PowerShell.

Function GetFileNames([string]$path, [string]$outputFile) {
  $list = Get-ChildItem $path -Recurse
  $list | Select-Object BaseName, FullName | Export-Csv $outputFile

GetFileNames ".\" "C:\Output.csv"
Read more from PowerShell
6 Comments Post a comment
  1. Afif Khaja
    Jul 10 2017

    Perfect and well-written code. Thank you!

  2. Jaan Deen
    Nov 15 2017

    Still useful in 2017!! Better organized code than what I found on the Net.

  3. Jaan Deen
    Nov 15 2017

    If you do *not* want the empty folder names… and only a file name list… remodify this line to the following:

    $list = Get-ChildItem $path -Recurse | where {!$_.PSIsContainer}

  4. Akarsh Verma
    Aug 3 2018

    Great work… I have taken the liberty of creating a public gist for this. Do let me know if that is a concern.

  5. Sep 5 2018

    I have noticed you don’t monetize your page, don’t waste
    your traffic, you can earn additional cash every month.
    You can use the best adsense alternative for any type of website
    (they approve all websites), for more info simply search in gooogle:
    boorfe’s tips monetize your website

  6. Dec 6 2018

    I don’t even know how I stopped up here, however I thought this publish was
    once great. I don’t realize who you might be but definitely you’re going
    to a famous blogger for those who are not
    already. Cheers!

Share your thoughts, post a comment.


Note: HTML is allowed. Your email address will never be published.

Subscribe to comments