|
|
楼主 |
发表于 2023-9-19 16:27:37
|
显示全部楼层
回复 thp2008
请参考Q-04把bat文件保存为ANSI编码:
Batcher 发表于 2023-9-19 14:49 
感谢老大,我测试了一下,基本上可行,只是有一点小逻辑性问题:
就是我需要运行两次这个批处理才能满足要求,第一次,不能删除,复制过去的文件.bc!
再运行一次就删除了。但是两次运行都会再复制一次,测试的小文件,没关系,但是大文件,就很浪费时间。我根据你提供的代码 ,修改了一下,已经可以了。- @echo off
- set "xl=F:\XunLei\原创精品电影1000GB电影"
- set "bt=E:\BitComet\原创精品电影1000GB电影"
- echo 正在检查并移动文件...
- for /f "delims=" %%i in ('dir /b /s /a-d "%xl%" ^| findstr /v /i /e /c:".bt.xltd"') do (
- set "SourceFolder=%%~dpi"
- set "SourceFile=%%~nxi"
- set "bcfile=%%~nxi.bc!"
- setlocal enabledelayedexpansion
- set "DestinationFolder=!SourceFolder:%xl%=%bt%!"
- if not exist "!DestinationFolder!" md "!DestinationFolder!"
- if exist "!DestinationFolder!!bcfile!" (
- echo 删除BitComet目录已存同名的.bc!文件: "!DestinationFolder!!bcfile!"
- del /f /q "!DestinationFolder!!bcfile!"
- )
- if not exist "!DestinationFolder!!SourceFile!" (
- echo 开始复制文件: "!SourceFolder!!SourceFile!" "!DestinationFolder!"
- copy /y "!SourceFolder!!SourceFile!" "!DestinationFolder!"
- )
-
- endlocal
- )
- pause
复制代码 |
|