have Powershell get-childitem return files only
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping
--
Chapters
00:00 Question
00:27 Accepted answer (Score 97)
00:39 Answer 2 (Score 155)
00:58 Answer 3 (Score 0)
01:18 Thank you
--
Full question
https://superuser.com/questions/150748/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#powershell
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping
--
Chapters
00:00 Question
00:27 Accepted answer (Score 97)
00:39 Answer 2 (Score 155)
00:58 Answer 3 (Score 0)
01:18 Thank you
--
Full question
https://superuser.com/questions/150748/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#powershell
#avk47
ANSWER 1
Score 163
In Powershell 3.0, it is simpler,
gci -Directory #List only directories
gci -File #List only files
This is even shorter,
gci -ad # alias for -Directory
gci -af # alias for -File
ACCEPTED ANSWER
Score 103
Try this:
gci . *.* -rec | where { ! $_.PSIsContainer }
ANSWER 3
Score 1
This is not working when anyone named the folder xxx.PDF:
get-childitem -Recurse -include *.pdf
Best then you can do:
Get-ChildItem -Recurse -Include *.pdf | where { ! $_.PSIsContainer }
ANSWER 4
Score 0
In PowerShell 7, one can use -File
switch:
Get-ChildItem *.pdf -Recurse -File