Have Powershell get-childitem return files only

powershell

I'd like to use get-childitem recursively, but only have it return files not directories. The best solution I have just doesn't seem natural:

gci . *.* -rec | where { $_.GetType().Name -eq "FileInfo" }

Best Answer

Try this:

gci . *.* -rec | where { ! $_.PSIsContainer }