China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 00:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Batch script to copy files every three minutes View 3,171 Replies 23
Original Poster Posted 2006-02-23 07:15 ·  中国 湖北 武汉 电信
新手上路
Credits 10
Posts 2
Joined 2006-02-23 07:13
20-year member
UID 50804
Status Offline
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 ]
Floor 2 Posted 2006-02-23 18:55 ·  中国 上海 闵行区 电信
中级用户
★★
大师兄
Credits 377
Posts 99
Joined 2005-08-26 07:37
20-year member
UID 41945
Status Offline
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, Credits to download 1 pts, Downloads: 74)
Floor 3 Posted 2006-02-23 19:30 ·  中国 浙江 衢州 电信
银牌会员
★★★
Credits 1,270
Posts 548
Joined 2004-05-31 00:00
22-year member
UID 25754
Gender Male
Status Offline
Floor 4 Posted 2006-02-23 20:55 ·  中国 广东 广州 番禺区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
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 ]
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 5 Posted 2006-03-27 19:05 ·  中国 广东 广州 中移铁通
中级用户
★★
Credits 256
Posts 93
Joined 2006-03-26 22:12
20-year member
UID 52853
Gender Male
From 广东
Status Offline
@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 ]
Floor 6 Posted 2006-03-27 23:16 ·  中国 福建 泉州 石狮市 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
I also post one

@echo off
:start
copy /y c:\log\log.log d:\logbak\log.log
choice /T 180 /d y
goto start
QQ:366840202
http://chenall.net
Floor 7 Posted 2006-03-28 22:51 ·  中国 广东 广州 中移铁通
中级用户
★★
Credits 256
Posts 93
Joined 2006-03-26 22:12
20-year member
UID 52853
Gender Male
From 广东
Status Offline
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
Floor 8 Posted 2006-03-28 23:30 ·  中国 河北 保定 移动
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Just copy it over. Choice seems to have two versions.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 9 Posted 2006-03-29 00:51 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
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.
Floor 10 Posted 2006-03-29 11:06 ·  中国 广东 深圳 福田区 电信
初级用户
★★
Credits 133
Posts 57
Joined 2006-03-15 23:12
20-year member
UID 52128
Status Offline
Originally posted by chenall at 2006-3-27 23:16:
I'll also post one

@echo off
:start
copy /y c:\log\log.log d:\logbak\log.log
choice /T 180 /d y
goto start

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 ]
Floor 11 Posted 2006-03-29 17:07 ·  中国 福建 泉州 石狮市 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
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]
QQ:366840202
http://chenall.net
Floor 12 Posted 2006-03-29 17:33 ·  中国 广东 广州 中移铁通
中级用户
★★
Credits 256
Posts 93
Joined 2006-03-26 22:12
20-year member
UID 52853
Gender Male
From 广东
Status Offline
 
What is the function of "
"?

----------------------------------------
Oh, I got it.



[ Last edited by doscc on 2006-3-29 at 17:37 ]
Floor 13 Posted 2006-04-04 10:35 ·  中国 浙江 宁波 电信
初级用户
Credits 40
Posts 13
Joined 2006-03-11 15:43
20-year member
UID 51811
Gender Male
From 浙江温州曾在宁波
Status Offline
那我是菜菜鸟,pengpeng能不能传个C的样本上来我:P好好学学?谢谢阿!

那 I'm a newbie, can pengpeng upload a C sample for me to learn from :P? Thanks ah!
Floor 14 Posted 2006-04-09 01:00 ·  中国 浙江 杭州 电信
银牌会员
★★
三生缘里笑红尘
Credits 1,063
Posts 292
Joined 2003-03-09 00:00
23-year member
UID 1073
Gender Male
Status Offline
Not bad, bad~ received
Floor 15 Posted 2007-03-12 00:53 ·  中国 陕西 西安 雁塔区 电信
新手上路
Credits 7
Posts 4
Joined 2007-01-23 04:03
19-year member
UID 77393
Gender Female
Status Offline
They are all experts, let's study!
Forum Jump: