Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - DIR problem

Reply
 
Old 01-07-2007   #1 (permalink)
Pisioo


 
 

DIR problem

I have a folder "c:\test" with two files in it "test.txt" and "test.xls".
When I run cmdlet "dir c:\test -Exclude *.xls" the cmdlet is executed as
expected - it returns the txt file, however cmdlet "dir c:\test -Include
*.txt" returns nothing. Anybody could explain it ?

My System SpecsSystem Spec
Old 01-07-2007   #2 (permalink)
uj


 
 

Re: DIR problem


Pisioo wrote:
> I have a folder "c:\test" with two files in it "test.txt" and "test.xls".
> When I run cmdlet "dir c:\test -Exclude *.xls" the cmdlet is executed as
> expected - it returns the txt file, however cmdlet "dir c:\test -Include
> *.txt" returns nothing. Anybody could explain it ?


Get-Help excerpt:

-include <string[]>
Retrieves only the specified items. The value of this parameter
qualifies the Path parameter. Enter a path element or pattern, such as
"*.txt". Wildcards are permitted. The Include parameter is effective
only when the command includes the Recurse parameter or the path leads
to the contents of a directory, such as C:\Windows\*, where the
wildcard character specifies the contents of the C:\Windows directory.

So, you should write "dir c:\test\* -Include *.txt"

My System SpecsSystem Spec
Old 01-07-2007   #3 (permalink)
halfix


 
 

RE: DIR problem

That's an easy one.

The help explanation for -include states:

"-include <string[]>
....
The Include parameter is effective only when the command includes the
Recurse parameter or the path leads to the contents of a directory, such as
C:\Windows\*, where the wild card character specifies the contents of the
C:\Windows directory."

Try "dir c:\test\* -Include *.txt"

"Pisioo" wrote:

> I have a folder "c:\test" with two files in it "test.txt" and "test.xls".
> When I run cmdlet "dir c:\test -Exclude *.xls" the cmdlet is executed as
> expected - it returns the txt file, however cmdlet "dir c:\test -Include
> *.txt" returns nothing. Anybody could explain it ?

My System SpecsSystem Spec
Old 01-10-2007   #4 (permalink)
Andrew Watt [MVP]


 
 

Re: DIR problem

Hi,

The semantics of the get-childitem cmdlet have given rise to concern
during the development of PowerShell 1.0. See, for example,
https://connect.microsoft.com/feedba...9321&SiteID=99.
Unfortunately, in my view, fixing these issues was postponed beyond
release of version 1.0.

In your scenario most people would expect

dir C:\Test -Include Test.txt

and

dir C:\Test\* -Include Test.txt

to give the same results. They don't, as you can confirm. That seems
to me to be undesirable behaviour.

Can any of the PowerShell team comment on when it is planned that the
semantics will be reviewed and fixed?

Thanks

Andrew Watt MVP

On Sun, 7 Jan 2007 07:38:01 -0800, Pisioo
<Pisioo@discussions.microsoft.com> wrote:

>I have a folder "c:\test" with two files in it "test.txt" and "test.xls".
>When I run cmdlet "dir c:\test -Exclude *.xls" the cmdlet is executed as
>expected - it returns the txt file, however cmdlet "dir c:\test -Include
>*.txt" returns nothing. Anybody could explain it ?

My System SpecsSystem Spec
Old 01-10-2007   #5 (permalink)
Lee Holmes [MSFT]


 
 

Re: DIR problem

There is no definite timeline for its fix, although this is something that
we are aware of, and indeed want to make right.

--
Lee Holmes [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:6ps9q2hh7e4our79civ9hgi1hgubnnu9a4@4ax.com...
> Hi,
>
> The semantics of the get-childitem cmdlet have given rise to concern
> during the development of PowerShell 1.0. See, for example,
> https://connect.microsoft.com/feedba...9321&SiteID=99.
> Unfortunately, in my view, fixing these issues was postponed beyond
> release of version 1.0.
>
> In your scenario most people would expect
>
> dir C:\Test -Include Test.txt
>
> and
>
> dir C:\Test\* -Include Test.txt
>
> to give the same results. They don't, as you can confirm. That seems
> to me to be undesirable behaviour.
>
> Can any of the PowerShell team comment on when it is planned that the
> semantics will be reviewed and fixed?
>
> Thanks
>
> Andrew Watt MVP
>
> On Sun, 7 Jan 2007 07:38:01 -0800, Pisioo
> <Pisioo@discussions.microsoft.com> wrote:
>
>>I have a folder "c:\test" with two files in it "test.txt" and "test.xls".
>>When I run cmdlet "dir c:\test -Exclude *.xls" the cmdlet is executed as
>>expected - it returns the txt file, however cmdlet "dir c:\test -Include
>>*.txt" returns nothing. Anybody could explain it ?



My System SpecsSystem Spec
Old 01-10-2007   #6 (permalink)
Keith Hill [MVP]


 
 

Re: DIR problem

"Lee Holmes [MSFT]" <lee.holmes@online.microsoft.com> wrote in message
news:uD6l9HONHHA.2236@TK2MSFTNGP02.phx.gbl...
> There is no definite timeline for its fix, although this is something that
> we are aware of, and indeed want to make right.
>


I wonder if the answer to this could be a modified wildcard syntax that
somehow allowed you to specify the exclude info as part of the search
pattern e.g.:

gci *.txt!foo*

or something like that. I'm a bit skeptical on the value of the -include
functionality since it seems that a more specific search pattern obviates
the need for the -Include parameter. This approach would also get rid of
two parameters (-Include and -Exclude).

--
Keith


My System SpecsSystem Spec
Old 01-15-2007   #7 (permalink)
Dudley LeRoux


 
 

Re: DIR problem

dir c:\test\*.txt


"Pisioo" <Pisioo@discussions.microsoft.com> wrote in message
news:81B4E9F9-0289-4841-9219-A67274977A13@microsoft.com...
>I have a folder "c:\test" with two files in it "test.txt" and "test.xls".
> When I run cmdlet "dir c:\test -Exclude *.xls" the cmdlet is executed as
> expected - it returns the txt file, however cmdlet "dir c:\test -Include
> *.txt" returns nothing. Anybody could explain it ?



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
the problem with ndis.sys Blue Screen of Death problem solved? Vista General
Re: Windows Mail Attachement Problem and Adobe Player Problem with IE8 Vista mail
Multi-select problem in Windows Explorer BIG PROBLEM!!!!!! Vista General
Generic McAfee Problem Message in Vista Problem Reports Vista performance & maintenance
Vista Upgrade Problem - Windows Explorer Loop problem Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46