@echo off
pushd %~dp0
rem 先输出文件和目录列表,如:
set srcDir=D:\winpe\wepe\CGI
set outDir=.\Build
dir /s /b /ad "%srcDir%\" >pe_folder.list
dir /s /b /a-d "%srcDir%\" >pe_file.list
:Build
dir *.list
for /f "delims=" %%i in (pe_folder.list) do mkdir "%outDir%\%%~pnxi"
for /f "delims=" %%i in (pe_file.list) do (
mkdir "%outDir%\%%~pi" 2>NUL
copy nul "%outDir%\%%~pnxi" /y
)
del /q pe_folder.list
del /q pe_file.list
exit
2、对比A、B两个目录,删除B目录下文件名在A目录中找不到对应的文件(由 junyee 坛友提供)
@echo off
set muiDir=D:\winpe\wepe\CGI\Windows\System32\zh-CN
set sysDir=D:\winpe\wepe\CGI\Windows\System32
for /f "delims=" %%i in ('dir /s /b %muiDir%\*.*') do (
if not exist "%sysDir%\%%~ni" del /f /q "%%i"
)
exit