# Get-ChildItem on Weird FolderNames

**URL:** <https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574>\
**Category:** PowerShell Help\
**Created:** [February 3, 2021, 5:41am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574 "2021-02-03T05:41:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian-clanton](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@brian-clanton](https://forums.powershell.org/u/brian-clanton)\
**Post date:** [February 3, 2021, 5:41am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/1 "2021-02-03T05:41:46Z")

</div>

I am writing a script that will get the ACL list of folders in their directory. The problem is, they have filenames/folders with hyphens and spaced that powershell’s ‘Get-ChildItem’ fails where it thinks it does not exist.

For Example, the folder ‘Dogtopia- Arlington’ does exist, but when I run the Get Childitem command on it, it doesn’t see it.

```
[cfs06]: PS G:\> Get-ChildItem 'G:\Shares\Schramm\BIDDING PROJECTS\Barrington Ramp\Dogtopia - Arlington Heights\Photos\10.2.19 Site Walk\Dogtopia- Arlington '
Get-ChildItem : Cannot find path 'G:\Shares\Schramm\BIDDING PROJECTS\Barrington Ramp\Dogtopia - Arlington Heights\Photos\10.2.19 Site Walk\Dogtopia- Arlington ' because it does not exist.
    + CategoryInfo : ObjectNotFound: (G:\Shares\Schra...pia- Arlington :String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
```

Just to prove that it is there…

```
[cfs06]: PS G:\> Get-ChildItem 'G:\Shares\Schramm\BIDDING PROJECTS\Barrington Ramp\Dogtopia - Arlington Heights\Photos\10.2.19 Site Walk'
 
 
    Directory: G:\Shares\Schramm\BIDDING PROJECTS\Barrington Ramp\Dogtopia - Arlington Heights\Photos\10.2.19 Site Walk
 
 
Mode LastWriteTime Length Name                                                                                                                                                                               
---- ------------- ------ ----                                                                                                                                                                               
d----- 10/3/2019 9:34 AM Dogtopia- Arlington                                                                                                                                                              
-a---- 10/3/2019 9:35 AM 6923919 Photo-2019-10-02-10-20-46_6553.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 6517015 Photo-2019-10-02-10-20-50_6554.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 6710406 Photo-2019-10-02-10-20-51_6555.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 5051907 Photo-2019-10-02-10-20-53_6556.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 5980265 Photo-2019-10-02-10-20-57_6557.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 7105864 Photo-2019-10-02-10-21-19_6558.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 6567256 Photo-2019-10-02-10-21-20_6559.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 6732866 Photo-2019-10-02-10-21-22_6560.JPG                                                                                                                                                 
-a---- 10/3/2019 9:35 AM 6341216 Photo-2019-10-02-10-21-24_6561.JPG
```

There are many different files that seem to error out. Even when I define the string in double quotes, it can’t find that item which I assume is because it has a hyphen and space in the name.

Is there a way I can accommodate these archaic naming conventions without having to rename files/folders. Renaming ‘might’ cause a bit of havoc since they use third party software that might reference files by name.

---

<div class="post-metadata">

**Author:** ![ferc](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ferc/32/2135_2.png) [@ferc](https://forums.powershell.org/u/ferc)\
**Post date:** [February 3, 2021, 6:49am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/2 "2021-02-03T06:49:16Z")

</div>

I have no way to test but have you tried using the ‘_LiteralPath_’ parameter?

---

<div class="post-metadata">

**Author:** ![grokkit](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/grokkit/32/970_2.png) [@grokkit](https://forums.powershell.org/u/grokkit)\
**Post date:** [February 3, 2021, 11:13am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/3 "2021-02-03T11:13:31Z")

</div>

The path in your command:  
`'G:\Shares\Schramm\BIDDING PROJECTS\Barrington Ramp\Dogtopia - Arlington Heights\Photos\10.2.19 Site Walk\Dogtopia- Arlington '`  
has an extra space at the end. Does the actual directory name have this trailing space?

You could also use the wildcard:  
`‘G:\Shares\Schramm\BIDDING PROJECTS\Barrington Ramp\Dogtopia - Arlington Heights\Photos\10.2.19 Site Walk\Dog**’`

---

<div class="post-metadata">

**Author:** ![dave-carnahan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dave-carnahan/32/12_2.png) [@dave-carnahan](https://forums.powershell.org/u/dave-carnahan)\
**Post date:** [February 3, 2021, 6:30pm UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/4 "2021-02-03T18:30:53Z")

</div>

The gentleman asking the question, about challenging subdirectory names, (or even filenames) has a very valid question to ask.

Seems as though, true developers are jumping around his question when it could be responded to directly, yes?\*

\*-And I’m very aware there are several different ways to address this challenge that we all get thrust onto, one globally, and the second explicitly.

Can anyone speak to these two methods precisely?

Ok, that’s my two cents.

Thanks folks!

Cheers

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [February 4, 2021, 6:30am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/5 "2021-02-04T06:30:22Z")

</div>

I think Grokkit has it figured, but we have not heard back.

I tested with similar folders as the original post and had no issues at all.

My $.02

---

<div class="post-metadata">

**Author:** ![brian-clanton](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@brian-clanton](https://forums.powershell.org/u/brian-clanton)\
**Post date:** [February 5, 2021, 3:52am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/6 "2021-02-05T03:52:57Z")

</div>

This appears to be the issue of trailing spaces in the folder and not the hyphen as Grokkit has pointed out. When I go to said folder above, I can’t rename it, delete it nor when I look at the security tab within Properties, I see “The requested security information is either unavailable or cant’ be displayed.”

The folder does not have a shortname as I see from the output ‘dir /x’, but it seems I have to address that issue and not so much the issue to get a complete ACL report on these folders.

&nbsp;

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [February 5, 2021, 7:19am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/7 "2021-02-05T07:19:53Z")

</div>

For some reason, your sentences are truncated. This site seems to do that at random. Not sure why. So, it is hard for me to get your drift.

If the folder is longer then 8 chars, it will have a shortname unless you have that turned off.

[https://support.microsoft.com/en-us/topic/how-to-disable-8-3-file-name-creation-on-ntfs-partitions-18496ea0-d086-701a-f4a5-17c05d370cf6](https://support.microsoft.com/en-us/topic/how-to-disable-8-3-file-name-creation-on-ntfs-partitions-18496ea0-d086-701a-f4a5-17c05d370cf6)

Glad you got it figured.

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 5, 2021, 11:24am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/8 "2021-02-05T11:24:35Z")

</div>

I suspect it happens when you insert code with the “\<\>” code formating tool from the “Visual” view and disable the line wrapping.  
In this case the controls move to the right outside of the screen size without having scroll bars to reach them.

---

<div class="post-metadata">

**Author:** ![grokkit](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/grokkit/32/970_2.png) [@grokkit](https://forums.powershell.org/u/grokkit)\
**Post date:** [February 8, 2021, 5:27am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/9 "2021-02-08T05:27:41Z")

</div>

The issue with text being cut off is due to very long strings that the forum doesn’t break and wrap to the next line. [Here is a demo](https://powershell.org/forums/topic/div-overflow-hyperlink-test/).

Unfortunately, this is not a result of any specific formatting that can be avoided while posting.  
It is an issue with the bbPress software and the theme that we are using for the forum. The post blocks adjust to fit the width of the content,  
but the display area that the post blocks are contained in has a fixed maximum width, so if the post blocks are too wide they break the edge of  
the display area. All post blocks are scaled to the same width, so if one block is too wide then all of them display inccorectly.

In this case, it’s the very long file path causing the problem. I could edit the post to make it display better (I did a little bit), but  
because the file path is the issue I couldn’t change the post too much without affecting the content.

In instances like this, the text is still being written to the page, it’s just hidden.  
When I need to read something from a post like this, I select the text and paste it into notepad.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [February 8, 2021, 5:31am UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/10 "2021-02-08T05:31:42Z")

</div>

Good to know. Thanks Grokkit 🙂

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/get-childitem-on-weird-foldernames/15574/11 "2024-05-16T20:27:52Z")

</div>

Closed on May 16, 2024, 8:27pm UTC


