0

I'm trying to figure out a solution for this

ex. paths

C:\Designs\CustomerA\PhotoshopFiles\

C:\Designs\CustomerB\PhotoshopFiles\

C:\Designs\CustomerC\PhotoshopFiles\

What I want to do is move the PhotoShopFiles folder to a different one (Customer Photoshop Files) and rename that folder to take the name of the folder it was contained in.

So I could have this structure:

C:\Designs\Customer Photoshop Files\CustomerA

C:\Designs\Customer Photoshop Files\CustomerB

C:\Designs\Customer Photoshop Files\CustomerC
Humberto Castellon
  • 849
  • 1
  • 7
  • 17

2 Answers2

0

Give this a shot for powershell

$newLocation = "C:\Designs\Customer Photoshop Files"
$folders = Get-ChildItem C:\Designs\ | select name, fullname

foreach ($folder in $folders) {
    Move-Item -Path $folder.fullname\PhotoshopFiles\ -Destination $newLocation\$folder.name -whatif
}

Remove the -whatif if it looks good.

Nixphoe
  • 4,524
  • 7
  • 32
  • 51
0
## Q:\Test\2018\10\23\sf_936862.ps1
#requires -Version 3.0
Get-ChildItem "C:\Designs" -Directory | Where-Object FullName -Notmatch "Customer Photoshop Files"|ForEach-Object {
    $Source = Join-Path $_.FullName "PhotoshopFiles\*"
    $Target = Join-Path "C:\Designs\Customer Photoshop Files" $_.Name
    If (!(Test-Path $Target)){MD $Target -Force| Out-Null}
    Get-ChildItem $Source | Move-Item -Destination $Target -Force
}

Sample tree after running the script:

> tree C: /f
C:\
└───Designs
    ├───Customer Photoshop Files
    │   ├───CustomerA
    │   │       a.jpg
    │   │
    │   ├───CustomerB
    │   │       b.jpg
    │   │
    │   └───CustomerC
    │           c.jpg
    │
    ├───CustomerA
    │   └───PhotoshopFiles
    ├───CustomerB
    │   └───PhotoshopFiles
    └───CustomerC
        └───PhotoshopFiles
LotPings
  • 1,015
  • 7
  • 12