Put the filenames of all files in a folder into a text file with Powershell

 
# Get-ChildItem (gci) is PowerShell's dir equivalent.
# -File limits the output to files.
# .BaseName extracts the file names without extension.
(Get-ChildItem -File).BaseName | Out-File files.txt

Get All the Files in the Folder and Sub-folders

# Set the output file path
$outputFile = "filelist.txt"
 
# Get the list of files
$files = Get-ChildItem -Recurse -Force
 
# Write the file names to the output file
$files | ForEach-Object { Add-Content -Path $outputFile -Value $_.Name }

📇 Additional Metadata

  • 🗂 Type:: note
  • 🏷️ Tags::
  • 📡 Status:: #status/🌲