have Powershell get-childitem return files only
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Cosmic Puzzle
--
Chapters
00:00 Have Powershell Get-Childitem Return Files Only
00:18 Accepted Answer Score 103
00:28 Answer 2 Score 163
00:43 Answer 3 Score 1
00:58 Answer 4 Score 0
01:06 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
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Cosmic Puzzle
--
Chapters
00:00 Have Powershell Get-Childitem Return Files Only
00:18 Accepted Answer Score 103
00:28 Answer 2 Score 163
00:43 Answer 3 Score 1
00:58 Answer 4 Score 0
01:06 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