← 返回
未分类

MPR文件复制

将共享26路径下面的MPR从 OUTPUT 复制到 OUTPUTWCC
user_3d7f50b0
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 11
下载
💾 0
安装
1
版本
#latest

概述

跨路径复制文件技能(.mpr 文件保护)

功能描述

\\10.23.252.26\output\{文件夹名称} 下的所有文件(含子文件夹)复制到 \\10.23.252.26\output_wcc\{文件夹名称}

核心规则:

  • 默认模式:.mpr 格式的同名文件不覆盖(跳过)
  • 全部替换模式:所有文件均覆盖(包括 .mpr

用户指令格式

1. 普通复制(保护 .mpr 文件)

复制 A221021 到 output_wcc
将 A221021 从 output 复制到 output_wcc
把 A221021 这个文件夹的东西复制过去

2. 全部替换(强制覆盖所有文件)

全部替换 A221021 到 output_wcc
强制复制 A221021 到 output_wcc
覆盖式复制 A221021

路径规则

变量
-----------
源根路径\\10.23.252.26\output
目标根路径\\10.23.252.26\output_wcc

文件夹名称:由用户提供,AI 自动拼入路径。


执行脚本(PowerShell)

普通复制(保护 .mpr)

param(
    [string]$FolderName
)

$source = "\\10.23.252.26\output\$FolderName"
$target = "\\10.23.252.26\output_wcc\$FolderName"

if (-Not (Test-Path $source)) {
    Write-Error "源文件夹不存在: $source"
    exit 1
}

if (-Not (Test-Path $target)) {
    New-Item -ItemType Directory -Path $target -Force | Out-Null
    Write-Host "已创建目标文件夹: $target"
}

$files = Get-ChildItem -Path $source -File -Recurse
$total = $files.Count
$copied = 0
$skipped = 0
$skippedMpr = @()
$failed = 0
$failedFiles = @()

Write-Host ""
Write-Host "══════════════════════════════════════════"
Write-Host " 复制文件(.mpr 文件保护模式)"
Write-Host " 源目录: $source"
Write-Host " 目标目录: $target"
Write-Host " 文件总数: $total"
Write-Host "══════════════════════════════════════════"
Write-Host ""

foreach ($file in $files) {
    $relativePath = $file.FullName.Substring($source.Length).TrimStart('\')
    $destPath = Join-Path $target $relativePath
    $destDir = Split-Path $destPath -Parent

    if (-Not (Test-Path $destDir)) {
        New-Item -ItemType Directory -Path $destDir -Force | Out-Null
    }

    # .mpr 文件保护:同名 .mpr 存在则跳过
    if ($file.Extension -eq '.mpr' -and (Test-Path $destPath)) {
        $skipped++
        $skippedMpr += $relativePath
        Write-Host "  [跳过] $relativePath (.mpr 保护)"
        continue
    }

    try {
        Copy-Item -Path $file.FullName -Destination $destPath -Force -ErrorAction Stop
        $copied++
        Write-Host "  [复制] $relativePath"
    } catch {
        $failed++
        $failedFiles += $file.FullName
        Write-Host "  [失败] $relativePath ($($_.Exception.Message))"
    }
}

Write-Host ""
Write-Host "══════════════════════════════════════════"
Write-Host " 执行完成"
Write-Host " 复制成功: $copied / $total"
Write-Host " 跳过(.mpr): $skipped"
if ($skipped -gt 0) {
    Write-Host " 被跳过的 .mpr 文件:"
    $skippedMpr | ForEach-Object { Write-Host "  - $_" }
}
if ($failed -gt 0) {
    Write-Host " 失败: $failed"
    $failedFiles | ForEach-Object { Write-Host "  - $_" }
}
Write-Host "══════════════════════════════════════════"

全部替换模式(强制覆盖)

param(
    [string]$FolderName
)

$source = "\\10.23.252.26\output\$FolderName"
$target = "\\10.23.252.26\output_wcc\$FolderName"

if (-Not (Test-Path $source)) {
    Write-Error "源文件夹不存在: $source"
    exit 1
}

if (-Not (Test-Path $target)) {
    New-Item -ItemType Directory -Path $target -Force | Out-Null
    Write-Host "已创建目标文件夹: $target"
}

$files = Get-ChildItem -Path $source -File -Recurse
$total = $files.Count
$copied = 0
$failed = 0
$failedFiles = @()

Write-Host ""
Write-Host "══════════════════════════════════════════"
Write-Host " 复制文件(全部替换模式)"
Write-Host " 源目录: $source"
Write-Host " 目标目录: $target"
Write-Host " 文件总数: $total"
Write-Host "══════════════════════════════════════════"
Write-Host ""

foreach ($file in $files) {
    $relativePath = $file.FullName.Substring($source.Length).TrimStart('\')
    $destPath = Join-Path $target $relativePath
    $destDir = Split-Path $destPath -Parent

    if (-Not (Test-Path $destDir)) {
        New-Item -ItemType Directory -Path $destDir -Force | Out-Null
    }

    try {
        Copy-Item -Path $file.FullName -Destination $destPath -Force -ErrorAction Stop
        $copied++
        Write-Host "  [复制] $relativePath"
    } catch {
        $failed++
        $failedFiles += $file.FullName
        Write-Host "  [失败] $relativePath ($($_.Exception.Message))"
    }
}

Write-Host ""
Write-Host "══════════════════════════════════════════"
Write-Host " 执行完成"
Write-Host " 复制成功: $copied / $total"
if ($failed -gt 0) {
    Write-Host " 失败: $failed"
    $failedFiles | ForEach-Object { Write-Host "  - $_" }
}
Write-Host "══════════════════════════════════════════"

AI 触发逻辑

  1. 识别用户提供的文件夹名称(提取厂编编号,如 A221021
  2. 识别操作模式
    • 含"全部替换" → 使用全部替换脚本
    • 普通指令 → 使用 .mpr 保护脚本
  3. 拼接完整路径并执行对应脚本
  4. 输出汇总报告

安全提示

  • 复制操作不影响源文件,仅拷贝
  • 目标端如有同名非 .mpr 文件,默认会被覆盖
  • 如需确认覆盖情况,可随时中断执行

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-06-10 10:22 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 382 📥 144,878
office-efficiency

Nano Pdf

steipete
使用nano-pdf CLI通过自然语言指令编辑PDF
★ 277 📥 116,132
office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 928 📥 186,911