本帖最后由 qixiaobin0715 于 2023-1-17 10:56 编辑
简化以上代码:- @echo off
- set SourceFolder=D:\abc
- set TargetFolder=D:\123
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in (list.txt) do (
- cd /d "%SourceFolder%"
- if "%%~xa"=="" (
- set "str=%%a.*"
- ) else (
- set "str=%%a"
- )
- for /f "delims=" %%i in ('dir /b /s /a-d "!str!"') do (
- set str=%%~dpi
- md "%TargetFolder%!str:%cd%=!">nul 2>nul
- copy "%%i" "%TargetFolder%!str:%cd%=!">nul 2>nul
- )
- )
- pause
复制代码
|