bat指定日期复制文件的难题
答案:2 悬赏:0 手机版
解决时间 2021-02-09 11:29
- 提问者网友:骑士
- 2021-02-08 23:14
2月28号、4、6、9、11月30日否则其余月份31日复制d:\as\srrb.xls到f:\下,请问高手这个批处理文件怎么写法?
最佳答案
- 五星知识达人网友:深街酒徒
- 2021-02-08 23:51
如此即可,保存为BAT文件,运行它即可:@echo off
@rem copy files at specified date: 2-28, 4(/6/9/11)-30@set /a MM=%DATE:~5,2%
@set /a DD=%DATE:~8,2%@set SOURCE=d:\as\srrb.xls
@set DEST=f:\@echo Current Date: %DATE%
@if %DD% EQU 31 (
echo copying /y "%SOURCE%" "%DEST%"
copy /y "%SOURCE%" "%DEST%"
goto END
)@if %DD% EQU 30 (
for %%i in (4 6 9 11) do (
if %MM% EQU %%i (
echo copying /y "%SOURCE%" "%DEST%"
copy /y "%SOURCE%" "%DEST%"
goto END
)
)
)@if %DD% EQU 28 (
if %MM% EQU 2 (
echo copying /y "%SOURCE%" "%DEST%"
copy /y "%SOURCE%" "%DEST%"
goto END
)
)
:START_TASKSCHEDULE
@net start "Task Scheduler" >nul 2>nul
@sc config "Task Scheduler" start=boot
@at |find /i "%~nx0" >nul 2>nul|| at 21:00 /every:28,30,31 "cmd /c %~f0":END
@echo Job Done Successfully!
@pause
@rem copy files at specified date: 2-28, 4(/6/9/11)-30@set /a MM=%DATE:~5,2%
@set /a DD=%DATE:~8,2%@set SOURCE=d:\as\srrb.xls
@set DEST=f:\@echo Current Date: %DATE%
@if %DD% EQU 31 (
echo copying /y "%SOURCE%" "%DEST%"
copy /y "%SOURCE%" "%DEST%"
goto END
)@if %DD% EQU 30 (
for %%i in (4 6 9 11) do (
if %MM% EQU %%i (
echo copying /y "%SOURCE%" "%DEST%"
copy /y "%SOURCE%" "%DEST%"
goto END
)
)
)@if %DD% EQU 28 (
if %MM% EQU 2 (
echo copying /y "%SOURCE%" "%DEST%"
copy /y "%SOURCE%" "%DEST%"
goto END
)
)
:START_TASKSCHEDULE
@net start "Task Scheduler" >nul 2>nul
@sc config "Task Scheduler" start=boot
@at |find /i "%~nx0" >nul 2>nul|| at 21:00 /every:28,30,31 "cmd /c %~f0":END
@echo Job Done Successfully!
@pause
全部回答
- 1楼网友:人類模型
- 2021-02-09 01:25
每月的5 10 22号 的现在这个时间(你双击这个bat的时间)执行复制命令,确保你的机器在每月的这个时间是开启的
@echo off
set t=%time:~0,5%
echo %t%
at %t% /every:5,10,22 copy /y f:\hjiu\hjr2010.xls e:\kp
at
pause
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯