中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-11 23:23
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » Batch script to copy files every three minutes
Printable Version  3,167 / 23
Floor1 yishu Posted 2006-02-23 07:15
新手上路 Posts 2 Credits 10
I want to use batch processing under DOS to copy c:\log\log.log to d:\logbak\log.log every three minutes. How to achieve it!


───────────────── Moderation Record ─────────────────
Performed by: Will Sort
Operation: Modify title: "19227 - Asking a super difficult question!"
Punishment: No points punishment as it's a new forum user
Prompt: Please visit {7326}Forum Newcomer Must-Read, Basic Code of Conduct for Everyone
───────────────── Moderation Record ─────────────────


[ Last edited by willsort on 2006-3-30 at 15:44 ]
Floor2 tigerpower Posted 2006-02-23 18:55
中级用户 Posts 99 Credits 377
Using sleep :

@echo off
:cycle
copy /y c:\log\log.log d:\logbak\log.log
sleep 180
goto cycle

Attachments
sleep.zip (7.49 KiB)
Floor3 weilong888 Posted 2006-02-23 19:30
银牌会员 Posts 548 Credits 1,270
Floor4 JonePeng Posted 2006-02-23 20:55
金牌会员 Posts 1,883 Credits 4,562 From 广东广州
The disadvantage of the program on the 2nd floor is that it cannot achieve background copying, which doesn't seem to meet the LZ's requirements, oh
I think the LZ's goal should be to design such a program: call interrupt handling, reside in memory, monitor in real time, copy in the background, and be able to continue running other programs. This is similar to Windows' Task Scheduler. Batch processing is difficult to do, but C language can.

[ Last edited by JonePeng on 2006-2-23 at 20:56 ]
Floor5 doscc Posted 2006-03-27 19:05
中级用户 Posts 93 Credits 256 From 广东
@echo off
copy c:\log\log.log d:\logbak\log.log

set mytime=%time:~3,2%
set wintime=%time:~0,3%

:t
set /A mytime+=3
if "%mytime%" GTR 60 set /A mytime-=60
if "%mytime%" == "60" set /A mytime=00

:m
set times=%time:~0,5%
set ti=%times:~3%
if "%ti%" == "00" set wintime=%time:~0,3%
if "%wintime%%mytime%" == "%times%" copy c:\log\log.log d:\logbak\log.log && goto t
goto m

[ Last edited by doscc on 2006-3-27 at 22:00 ]
Floor6 chenall Posted 2006-03-27 23:16
银牌会员 Posts 469 Credits 1,276 From 福建泉州
I also post one
Floor7 doscc Posted 2006-03-28 22:51
中级用户 Posts 93 Credits 256 From 广东
Such a useful command choice

But the cmd in my XP doesn't have this command.

I don't know why?

It's available in 2003
Floor8 Climbing Posted 2006-03-28 23:30
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
Just copy it over. Choice seems to have two versions.
Floor9 3742668 Posted 2006-03-29 00:51
荣誉版主 Posts 718 Credits 2,013
For XP, just use ping.
ping 1.1.1.1 -w 3000 -n 1
Set the number of times n to 1, which can make the time as precise as possible.
Floor10 kingchain Posted 2006-03-29 11:06
初级用户 Posts 57 Credits 133
Originally posted by chenall at 2006-3-27 23:16:
I'll also post one

This method is good!

May I ask how you do the {copy to slip}? I want to learn it

[ Last edited by kingchain on 2006-3-29 at 11:07 ]
Floor11 chenall Posted 2006-03-29 17:07
银牌会员 Posts 469 Credits 1,276 From 福建泉州
Add code code Example:
[code]
@echo off
:start
copy /y c:\log\log.log d:\logbak\log.log
choice /T 180 /d y
goto start
[/code]
Floor12 doscc Posted 2006-03-29 17:33
中级用户 Posts 93 Credits 256 From 广东


[ Last edited by doscc on 2006-3-29 at 17:37 ]
Floor13 warmoon Posted 2006-04-04 10:35
初级用户 Posts 13 Credits 40 From 浙江温州曾在宁波
那我是菜菜鸟,pengpeng能不能传个C的样本上来我:P好好学学?谢谢阿!

那 I'm a newbie, can pengpeng upload a C sample for me to learn from :P? Thanks ah!
Floor14 pizigao Posted 2006-04-09 01:00
银牌会员 Posts 292 Credits 1,063
Not bad, bad~ received
Floor15 fpqcj Posted 2007-03-12 00:53
新手上路 Posts 4 Credits 7
They are all experts, let's study!
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023