# Get-ChildItem and subfolder pathing

**URL:** <https://forums.powershell.org/t/get-childitem-and-subfolder-pathing/258>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/get-childitem-and-subfolder-pathing/258 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/get-childitem-and-subfolder-pathing/258/1 "2011-12-31T18:30:00Z")

</div>

by ChrisL at 2012-10-17 10:26:02

> This seems like such a simple issue but I haven’t been able to find anything on it. I’m using Get-ChildItem to recursively search through folder sets for particular text files, modify them, and then save the file. The problem I’ve been running into is that for files that are located in subfolders, instead of overwriting them, it saves them in the root folder instead. Is there a way to retreive the full path using GCI or is there a better way to do this?  
>   
> `	ForEach ($sFolder in $aSearchFolders) { If (Test-Path "$sFolder") { Set-Location $sFolder Get-ChildItem -Path $sFolder -Filter name*.xxx -Recurse | ForEach-Object { (Get-Content $) | ForEach-Object {$ -replace "text1", "text2"} | Set-Content $_ } }	}`

by DonJ at 2012-10-17 10:36:18

> The File object does contain the full path. The problem is that you’re using $_, which is the whole file object, so it’s defaulting to the Name property. You probably want to use something like $_.FullName instead.

by ChrisL at 2012-10-17 11:53:32

> That fixed it; thank you so much!!

---

<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, 9:03pm UTC](https://forums.powershell.org/t/get-childitem-and-subfolder-pathing/258/2 "2024-05-16T21:03:31Z")

</div>

Closed on May 16, 2024, 9:03pm UTC


