![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Get-Childitem filter files with multiple extensions? Is there any way to run a get-childitem and filter for multiple objects? Example Get-Childitem -path C:\ -filter *.log,*.txt I guess I could enter the extensions in an array and run though a loop appending the results? Just wondering if there was an easier way |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Get-Childitem filter files with multiple extensions? Use the -Include parameter to qualify the -Path which should have a '\*' ls c:\* -i *.log, *.txt -- Kiron |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Get-Childitem filter files with multiple extensions? Try this. Include takes an array and filter only uses one string. dir -path c:\data -Include @("*.txt","*.log") -rec Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject a> Is there any way to run a get-childitem and filter for multiple a> objects? a> Example a> Get-Childitem -path C:\ -filter *.log,*.txt a> I guess I could enter the extensions in an array and run though a a> loop appending the results? Just wondering if there was an easier a> way a> |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Get-Childitem filter files with multiple extensions? Nice. Thanks. I was on right track...I did -include "*.txt,*.log" instead but it obviously failed. Thanks for your help! "Brandon Shell [MVP]" wrote: Quote: > Try this. Include takes an array and filter only uses one string. > > dir -path c:\data -Include @("*.txt","*.log") -rec > > Brandon Shell > --------------- > Blog: http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > a> Is there any way to run a get-childitem and filter for multiple > a> objects? > a> Example > a> Get-Childitem -path C:\ -filter *.log,*.txt > a> I guess I could enter the extensions in an array and run though a > a> loop appending the results? Just wondering if there was an easier > a> way > a> > > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Get-Childitem filter files with multiple extensions? Hi akcorr, You can with -include, just make sure to add the '*' wildcard to the end of the path (it leads to the contents of the directory). You can omit the wildcard if you specify -recurse: PS > Get-Childitem -path C:\* -include *.log,*.txt --- Shay Levy Windows PowerShell MVP blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic a> Is there any way to run a get-childitem and filter for multiple a> objects? a> Example a> Get-Childitem -path C:\ -filter *.log,*.txt a> I guess I could enter the extensions in an array and run though a a> loop appending the results? Just wondering if there was an easier a> way a> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Get-Childitem filter files with multiple extensions? Thanks Keith. -- Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| should this work: Get-ChildItem -Path * -Filter *.ps1 -Recurse | PowerShell | |||
| Finding multiple file extensions | Vista file management | |||
| Opening Multiple Files w/ Different Extensions | Vista performance & maintenance | |||
| Search for Multiple Extensions | Vista General | |||
| -filter multiple file extensions | PowerShell | |||