比较来自世界各地的卖家的域名和 IT 服务价格

使用 Robocopy 或者 Powershell 搜索文件夹,重命名和移动

我正试图找到一个解决方案

例如 小路

C:\Designs\CustomerA\PhotoshopFiles\

C:\Designs\CustomerB\PhotoshopFiles\

C:\Designs\CustomerC\PhotoshopFiles\

我想移动文件夹 PhotoShopFiles 在另一个 (客户端文件 Photoshop) 并通过拍摄所在文件夹的名称来重命名此文件夹。

所以,我可以拥有这样的结构:

C:\Designs\Customer Photoshop Files\CustomerA

C:\Designs\Customer Photoshop Files\CustomerB

C:\Designs\Customer Photoshop Files\CustomerC
已邀请:

郭文康

赞同来自:

## 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
}

启动脚本后的树示例:

> tree C: /f
C:\
└───Designs
├───Customer Photoshop Files
│ ├───CustomerA
│ │ a.jpg
│ │
│ ├───CustomerB
│ │ b.jpg
│ │
│ └───CustomerC
│ c.jpg

├───CustomerA
│ └───PhotoshopFiles
├───CustomerB
│ └───PhotoshopFiles
└───CustomerC
└───PhotoshopFiles

莫问

赞同来自:

拿一个快照 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
}

消除 -whatif, 如果他看起来不错。

要回复问题请先登录注册