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