批处理复制文件 排除EXE DLL 类型文件

来源:百度知道 编辑:UC知道 时间:2024/04/30 04:06:28
我做了个批处理复制指定文件夹的内容,但是想排除其中的.EXE文件,还.DLL文件,原批处理文件如下:
@echo off
del d:\txl\addx2.reg
regedit /s d:\txl\add.reg
copy /y \\x2\txl\*.* d:\txl
regedit /s d:\txl\addx2.reg
start d:\txl\octxl.exe
我太懂,请说详细点,或者,直接给出答案,我要排除的就是\x2\txl\*.EXE和\x2\txl\*.DLL其实也就是两个文件,假设文件为, 1.exe 2.dll,排除这两个就可以了

@echo off
for /r "\\x2\txl" %%i in (*)do (
if %%~xi neq .exe if %%~xi neq .dll copy /y "%%i" "d:\txl" )
::排除其中的.EXE文件,.DLL文件

用FOR循环
for %%a in (.exe .dll) do (
if 文件名后三位 不等于 %%a (拷贝文件)
)
至于判断文件后缀 你可以看看取字符串的方法

@echo off
del d:\txl\addx2.reg
regedit /s d:\txl\add.reg
for /f "delims=" %%a in ('dir/b "\\x2\txl\"^|find /v ".exe"^|find /v ".dll"') do (copy /y "\\x2\txl\%%a" d:\txl)
regedit /s d:\txl\addx2.reg
start d:\txl\octxl.exe

BB石俊杰 的方法是最好的。