![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | =?Utf-8?Q?Puzzle:_=E2=80=9Cgci_-r_-n=E2=80=9D_vs._=E2=80=9Cgci_*_-?==?Utf-8?Q?r_-n=E2=80=9D?= I would rather expect that the commands: Get-ChildItem -recurse -name Get-ChildItem * -recurse -name are the same. But the results are slightly different: *) the first produces subdirectory names; the second does not; *) the first produces relative paths with file names; the second produces just file names without paths. Could anybody explain these differences? If it is a feature, I would like to understand the logic. -- Thanks, Roman |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Puzzle: =?UTF-8?B?4oCcZ2NpIC1yIC1u4oCdIHZzLiDigJxnY2kgKiAtciA=?==?UTF-8?B?LW7igJ0=?= Roman Kuzmin wrote: > I would rather expect that the commands: > > Get-ChildItem -recurse -name > Get-ChildItem * -recurse -name > > are the same. But the results are slightly different: > > *) the first produces subdirectory names; the second does not; > *) the first produces relative paths with file names; the second produces > just file names without paths. > > Could anybody explain these differences? If it is a feature, I would like to > understand the logic. > Get-ChildItem -recurse -name is the same as Get-ChildItem . -recurse -name (the current directory) not Get-ChildItem * -recurse -name (all subdirectories) |
My System Specs![]() |
| | #3 (permalink) |
| | =?Utf-8?Q?RE:_Puzzle:_=E2=80=9Cgci_-r_-n=E2=80=9D_vs._=E2=80=9Cgci?==?Utf-8?Q?_*_-r_-n=E2=80=9D?= Roman, I'll let the devs jump in here with the rationale, but I have slight correction for the assumptions. If this isn't clear, please let me know. The default value for the Path parameter in Get-Childitem is the current directory. But PS distinguishes between the directory itself -- the container (.) -- and its contents (*). In this case, the default value is the directory itself (.), so these two command should be the same, and the results are, in fact, identical. gci -r -n gci . -r -n The * case (gci * -n -r) is interesting, though. It will list the contents of the subdirectories first, then lists the contents of the current directory last. Also, a subdirectory that has no contents doesn't appear at all. -- June Blender [MSFT] Windows PowerShell Documentation Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. "Roman Kuzmin" wrote: > I would rather expect that the commands: > > Get-ChildItem -recurse -name > Get-ChildItem * -recurse -name > > are the same. But the results are slightly different: > > *) the first produces subdirectory names; the second does not; > *) the first produces relative paths with file names; the second produces > just file names without paths. > > Could anybody explain these differences? If it is a feature, I would like to > understand the logic. > > -- > Thanks, > Roman |
My System Specs![]() |
| | #4 (permalink) |
| | =?Utf-8?Q?RE:_Puzzle:_=E2=80=9Cgci_-r_-n=E2=80=9D_vs._=E2=80=9Cgci?==?Utf-8?Q?_*_-r_-n=E2=80=9D?= Thanks all, perhaps I have got the idea. But if it is so, then: -Path currently deals with both directories and files. It puzzles me and the others (see the nearby thread "Do the *-item cmdlets really need a -include parameter?"). If the name of the cmdlet is Get-ChildItem - thus, IMO, the primary goal is to specify directories/containers which child items should be returned. Let -Path does that (i.e. actually defines directories/containers; files do not have child items!). Child items specification is the secondary goal; let -Include and -Exclude do that. Thus, according to the above the command Get-ChildItem * must not return files in the current directory because * defines all directories in the current directory but not the current directory itself. Get-ChildItem . or Get-Item * should return them. And the command Get-ChildItem X where X is a file should return nothing simply because X has no child items; instead, Get-Item X should return X. This is just my quick and not really serious try to bring some logic into the issue. Get-ChildItem is one of the most important cmdlets. Almost everybody will start getting familiar with PowerShell playing with it. It has to be well done and well documented, ambiguities should be avoided. The current help topic is far from ideal and simply has mistakes. I do not complain at all, the product is not yet released. Actually I do love PowerShell already. -- Thanks, Roman |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Puzzle | Vista music pictures video | |||
| Puzzle | Vista music pictures video | |||
| Puzzle | Vista music pictures video | |||
| graphics -puzzle | Vista General | |||
| Fun Puzzle? | Vista mail | |||