|
|
发表于 2018-12-17 17:04:55
|
显示全部楼层
本帖最后由 xczxczxcz 于 2018-12-17 17:06 编辑
回复 17# cxy03791695766
先运行脚本 按提示操作, 文件名长度不能超过80个字符。脚本可放任意位置。若手工输入需要完整路径。
- $A文件夹=Read-host -Prompt "拖入 A 文件夹 并回车"
- $B文件夹=Read-host -Prompt "拖入 B 文件夹 并回车"
- gci "$A文件夹" -Directory|%{
- foreach ($Number in @($_.name.Split('_-'))) {
- $err=$null
- foreach ($i in ($Number.GetEnumerator())){
- if (![Char]::IsDigit("$i")){$err='yes'}
- }
- if (!$err){$Folder=$Number}
- }
- if([Io.Directory]::Exists("$B文件夹\$Folder")){
- Get-Item "$($_.fullname)\*"|%{
- Copy $_.Fullname -Dest "$B文件夹\$Folder\" -Recurse -Force
- if ($?){Write-host '复制文件:'$_.Fullname -fore Magenta}
- }
- }
- }
- pause
复制代码 ==============enjoy================ |
|