- @echo off
- setlocal enabledelayedexpansion
- set /p "zf= 输入字符(如 *.txt;a*.txt;???s.*):"
- set /p "lj= 设置你要备份的路径(如 c:\):"
- echo 正在全盘搜索......
- md "%lj%"
- for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
- if exist %%a:\ (
- for /f "tokens=*" %%i in ('dir /a /b /s "%%a:\%zf%"') do (
- if exist "%lj%\%%~nxi" (
- call :GetNewName "%%~nxi"
- echo f | xcopy /h /y "%%i" "%lj%\!NewFile!"
- ) else (
- xcopy /h /y "%%i" "%lj%\"
- )
- )
- )
- )
-
- :GetNewName
- set "name=%~n1"
- set "ext=%~x1"
- set n=1
- :LoopName
- if exist "%lj%\%name%_!n!%ext%" (
- set /a n+=1
- goto :LoopName
- )
- set NewFile=%name%_!n!%ext%
复制代码 上面的能运行 可是我把跟他其他的放在一起之后复制代码 搜索就不完全了 |