移动文件命令

来源:互联网 发布:淘宝汽车用品好做吗 编辑:程序博客网 时间:2024/06/03 17:20
@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 offfor /r %%a in (*.txt) do set n=0&call:checkfile "%%~a"pause&exitgoto :eof:checkfileif not exist "d:\aaa\%~n1%n%%~x1" (    move "%~1" "d:\aaa\%~n1%n%%~x1") else (set/a n+=1goto checkfile)
-------------------------------------

原创粉丝点击