You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows系统中如何批量复制/移动指定名称的文件夹?

Windows批量复制/移动指定文件夹的方法

方法一:批处理脚本(上手简单)

  1. 把需要操作的文件夹名称整理成文本文件,命名为folders.txt,每行写一个文件夹名,放在你的主目录里。
  2. 新建文本文件,粘贴下面代码,替换source_dir和target_dir为你的实际路径,保存成.bat后缀的批处理文件(比如batch_copy.bat):
@echo off
set "source_dir=C:\Users\你的用户名"
set "target_dir=D:\最终目录"

if not exist "%target_dir%" mkdir "%target_dir%"

for /f "delims=" %%i in (folders.txt) do (
    if exist "%source_dir%\%%i\" (
        xcopy "%source_dir%\%%i" "%target_dir%\%%i\" /E /H /C /I /Y
        echo 已复制:%%i
    ) else (
        echo 未找到文件夹:%%i
    )
)
pause
  • 如果要改成移动操作,把代码里的xcopy换成move,即:move "%source_dir%\%%i" "%target_dir%\"
  • 参数说明:/E复制所有子目录(包括空目录),/H包含隐藏和系统文件,/Y覆盖文件不弹窗提示。

方法二:PowerShell脚本(适配特殊名称更稳定)

PowerShell对带空格、特殊字符的文件夹名支持更好,步骤如下:

  1. 同样准备好folders.txt(每行一个文件夹名)放在主目录。
  2. 新建文本文件,粘贴下面代码,替换路径后保存成.ps1后缀的脚本(比如batch_move.ps1):
$sourceDir = "C:\Users\你的用户名"
$targetDir = "D:\最终目录"
$folderList = Get-Content -Path "$sourceDir\folders.txt"

# 目标目录不存在就创建
if (-not (Test-Path -Path $targetDir)) {
    New-Item -ItemType Directory -Path $targetDir | Out-Null
}

foreach ($folder in $folderList) {
    $sourcePath = Join-Path -Path $sourceDir -ChildPath $folder
    $targetPath = Join-Path -Path $targetDir -ChildPath $folder
    if (Test-Path -Path $sourcePath -PathType Container) {
        # 复制操作
        Copy-Item -Path $sourcePath -Destination $targetPath -Recurse -Force
        Write-Host "已复制:$folder"
        # 换成移动操作就注释上面的Copy-Item,取消下面的注释
        # Move-Item -Path $sourcePath -Destination $targetPath -Force
    } else {
        Write-Host "未找到文件夹:$folder"
    }
}
  • 运行脚本:右键点击脚本,选择“用PowerShell运行”即可。

方法三:第三方可视化工具(无需写代码)

  • Total Commander:打开主目录后,点击菜单栏「选择」→「选择文件/文件夹」,导入你的folders.txt列表,选中目标文件夹后直接拖到最终目录,选择复制或移动即可。
  • Multi Commander:操作逻辑类似Total Commander,支持从文本文件批量选择文件夹,一键执行移动/复制,界面更简洁。

内容的提问来源于stack exchange,提问作者Elsa James

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 03:05:33