@echo off
set n=0
:checkfile
if not exist "E:\agent_jar\agent%n%.jar" (
move "E:\datacloudWorkspace\agent_javarasp_1.0\target\agent_javarasp_1.0-0.0.1-SNAPSHOT-jar-with-dependencies.jar" "E:\agent_jar\agent%n%.jar"
) else (
set/a n+=1
goto checkfile
)
pause
存在则将自动加上序号,不更改源文件
----------------------------------------------------------
强制覆盖:
@echo off
move /Y "E:\datacloudWorkspace\agent_javarasp_1.0\target\agent_javarasp_1.0-0.0.1-SNAPSHOT-jar-with-dependencies.jar" "E:\agent_jar\agent.jar"
pause
----------------------------------------------------------
但是我要移动的文件不一定是abc.txt,有abc.txt,begin.txt,aa.txt等等,总之有很多……
准确来说就是把一个目录下及其子目录下的所有txt文件移动到d:\aaa\目录下
而这些txt文档中有不少文件是同名,但是内容不一样,所以不是覆盖,然后向通过加一个数字编号来区分……额,就是这样了
追答
@echo off
for /r %%a in (*.txt) do set n=0&call:checkfile "%%~a"
pause&exit
goto :eof
:checkfile
if not exist "d:\aaa\%~n1%n%%~x1" (
move "%~1" "d:\aaa\%~n1%n%%~x1"
) else (
set/a n+=1
goto checkfile
)
-------------------------------------