# Moving contents of source to destination with similar name

**URL:** <https://forums.powershell.org/t/moving-contents-of-source-to-destination-with-similar-name/20523>\
**Category:** PowerShell Help\
**Created:** [September 25, 2022, 11:57pm UTC](https://forums.powershell.org/t/moving-contents-of-source-to-destination-with-similar-name/20523 "2022-09-25T23:57:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackfalveyiv](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jackfalveyiv](https://forums.powershell.org/u/jackfalveyiv)\
**Post date:** [September 25, 2022, 11:57pm UTC](https://forums.powershell.org/t/moving-contents-of-source-to-destination-with-similar-name/20523/1 "2022-09-25T23:57:47Z")

</div>

I have a weird problem, looking for the Powershell solution, but haven’t figured out the syntax yet…

I have a directory full of almost 40k folders. It used to be only 20k, but due to a new folder naming convention from an attached application, each folder got duplicated with a new name. They look like this:

C:\Directory\Subfolder1  
C:\Directory\Subfolder1 {dd-12345}

_ **NOTE** _ - Subfolder1 {dd-12345} has a random assortment of numbers and letters, but will always be appended with “{dd-”, and always closes with “}”

Subfolder1 has contents in it that I need to migrate to Subfolder1 {dd-12345}. Essentially I want my script to do this:

1. Get-Childitem ‘C:\Temp\SourceFolders\*’ -Recurse
2. For each folder, match the folder with a similar name and move the contents from the source folder (Subfolder1) to destination folder (Subfolder1 {dd-12345}).

- This is the piece I can’t figure out the logic for…struggling trying to use a match function with a foreach statement.

1. Remove-Item 'C:\Temp\SourceFolders\Subfolder1 -Recurse

Any help would be appreciated, thanks.

---

<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:** [September 26, 2022, 7:42am UTC](https://forums.powershell.org/t/moving-contents-of-source-to-destination-with-similar-name/20523/2 "2022-09-26T07:42:02Z")

</div>

> [@jackfalveyiv](#):
>
> For each folder, match the folder with a similar name and move the contents from the source folder (Subfolder1) to destination folder (Subfolder1 {dd-12345}).

Easy … look for folders with the desired pattern `{dd-12345}`, then split their name from this pattern and you have your folder you want to move into them. Or did I miss something? 🤷🏽‍♂️

---

<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:16pm UTC](https://forums.powershell.org/t/moving-contents-of-source-to-destination-with-similar-name/20523/3 "2024-05-16T20:16:35Z")

</div>


