![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | -filter multiple file extensions is it possible to use the -filter | -exclude | -include for multiple extensions, something like get-childitem d:\test -filter *.vob,*.mp3,*.avi i tried delimiting with ";" or "." or "," none worked -- $hay http://scriptolog.blogspot.com |
My System Specs![]() |
| | #2 (permalink) |
| | Re: -filter multiple file extensions Hi Shay, You can't do it using the -filter parameter since you are supplying an array as value to a parameter which takes a string. You can do it using -include but since you appear to have had problems with that you are probably hitting one of the "features" of get-childitem that, in my view, needs to be improved/corrected as soon as possible. Assume you are in the directory with the files. Then PS C:\PowerShellScripts\MP3> get-childitem -include *.mp3,*.vob returns nothing. But if you add the *, PS C:\PowerShellScripts\MP3> get-childitem * -include *.mp3,*.vob Directory: Microsoft.PowerShell.Core\FileSystem::C:\PowerShellScripts\MP3 Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 16/01/2007 08:57 14 Empty1.mp3 -a--- 16/01/2007 08:57 14 Empty1.vob -a--- 16/01/2007 08:57 14 Empty2.mp3 -a--- 16/01/2007 08:57 14 Empty2.vob -a--- 16/01/2007 08:57 14 Empty3.mp3 -a--- 16/01/2007 08:57 14 Empty3.vob it does what you wanted. The same anomaly of semantics occurs if you use the full paths. PS C:\PowerShellScripts\MP3> get-childitem C:\PowerShellScripts\MP3 -include *.mp3,*.vob PS C:\PowerShellScripts\MP3> get-childitem C:\PowerShellScripts\MP3\* -include *.mp3,*.vob Directory: Microsoft.PowerShell.Core\FileSystem::C:\PowerShellScripts\MP3 Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 16/01/2007 08:57 14 Empty1.mp3 -a--- 16/01/2007 08:57 14 Empty1.vob -a--- 16/01/2007 08:57 14 Empty2.mp3 -a--- 16/01/2007 08:57 14 Empty2.vob -a--- 16/01/2007 08:57 14 Empty3.mp3 -a--- 16/01/2007 08:57 14 Empty3.vob The presence or absence of the * is crucial to semantics. The semantics of get-childitem have been flagged as a very important bug for a long time. Unfortunately, it was resolved as "postponed" for PowerShell 1.0. See https://connect.microsoft.com/feedba...9321&SiteID=99 for an illustrative descriptionr of another of the problems of semantics with get-childitem. Since get-childitem can often be in an earlier pipeline step for move-item or remove-item it seems to me that the semantics of get-childitem need to be rock solid. At the moment that's not how I would describe them, unfortunately. I hope that helps. Andrew Watt MVP Author Professional Windows PowerShell (Wrox) On Tue, 16 Jan 2007 09:39:59 +0200, "$hay" <no@addre.ss> wrote: >is it possible to use the -filter | -exclude | -include >for multiple extensions, something like > >get-childitem d:\test -filter *.vob,*.mp3,*.avi > >i tried delimiting with ";" or "." or "," none worked > > >-- >$hay >http://scriptolog.blogspot.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: -filter multiple file extensions great just voted for it on connect --- $hay http://scriptolog.blogspot.com "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message news:as5pq29o2eahft5rp6ail02l3pubt38q4f@4ax.com... > Hi Shay, > > You can't do it using the -filter parameter since you are supplying an > array as value to a parameter which takes a string. > > You can do it using -include but since you appear to have had problems > with that you are probably hitting one of the "features" of > get-childitem that, in my view, needs to be improved/corrected as soon > as possible. > > Assume you are in the directory with the files. Then > > PS C:\PowerShellScripts\MP3> get-childitem -include *.mp3,*.vob > > returns nothing. > > But if you add the *, > > PS C:\PowerShellScripts\MP3> get-childitem * -include *.mp3,*.vob > > > Directory: > Microsoft.PowerShell.Core\FileSystem::C:\PowerShellScripts\MP3 > > > Mode LastWriteTime Length Name > ---- ------------- ------ ---- > -a--- 16/01/2007 08:57 14 Empty1.mp3 > -a--- 16/01/2007 08:57 14 Empty1.vob > -a--- 16/01/2007 08:57 14 Empty2.mp3 > -a--- 16/01/2007 08:57 14 Empty2.vob > -a--- 16/01/2007 08:57 14 Empty3.mp3 > -a--- 16/01/2007 08:57 14 Empty3.vob > > it does what you wanted. > > The same anomaly of semantics occurs if you use the full paths. > > PS C:\PowerShellScripts\MP3> get-childitem C:\PowerShellScripts\MP3 > -include *.mp3,*.vob > PS C:\PowerShellScripts\MP3> get-childitem C:\PowerShellScripts\MP3\* > -include *.mp3,*.vob > > > Directory: > Microsoft.PowerShell.Core\FileSystem::C:\PowerShellScripts\MP3 > > > Mode LastWriteTime Length Name > ---- ------------- ------ ---- > -a--- 16/01/2007 08:57 14 Empty1.mp3 > -a--- 16/01/2007 08:57 14 Empty1.vob > -a--- 16/01/2007 08:57 14 Empty2.mp3 > -a--- 16/01/2007 08:57 14 Empty2.vob > -a--- 16/01/2007 08:57 14 Empty3.mp3 > -a--- 16/01/2007 08:57 14 Empty3.vob > > > The presence or absence of the * is crucial to semantics. > > The semantics of get-childitem have been flagged as a very important > bug for a long time. Unfortunately, it was resolved as "postponed" for > PowerShell 1.0. See > https://connect.microsoft.com/feedba...9321&SiteID=99 > for an illustrative descriptionr of another of the problems of > semantics with get-childitem. > > Since get-childitem can often be in an earlier pipeline step for > move-item or remove-item it seems to me that the semantics of > get-childitem need to be rock solid. At the moment that's not how I > would describe them, unfortunately. > > I hope that helps. > > Andrew Watt MVP > Author Professional Windows PowerShell (Wrox) > > > On Tue, 16 Jan 2007 09:39:59 +0200, "$hay" <no@addre.ss> wrote: > >>is it possible to use the -filter | -exclude | -include >>for multiple extensions, something like >> >>get-childitem d:\test -filter *.vob,*.mp3,*.avi >> >>i tried delimiting with ";" or "." or "," none worked >> >> >>-- >>$hay >>http://scriptolog.blogspot.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Get-Childitem filter files with multiple extensions? | PowerShell | |||
| Finding multiple file extensions | Vista file management | |||
| Opening Multiple Files w/ Different Extensions | Vista performance & maintenance | |||
| Search for Multiple Extensions | Vista General | |||
| .doc file extensions | Vista General | |||