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 17:32
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » [Help] Can files be backed up automatically by date? Many thanks~ View 706 Replies 2
Original Poster Posted 2003-07-01 00:00 ·  中国 北京 北京宽捷网络信息技术有限公司
初级用户
Credits 103
Posts 1
Joined 2003-07-01 00:00
23-year member
UID 6217
Gender Male
Status Offline
I'm new here, hope everyone will look after me more
Right now I have a tricky problem: for example, my C:/abc/1.txt is a file that needs to be backed up often (possibly as often as every few hours). So I added a simple command to the startup batch file so that it gets backed up every time the system starts, but the filenames are always the same. Is there any way to automatically rename and save them using filenames based on "year month day hour" or "month day hour minute" (such as "03070115.txt" or "07011510.txt"? If so, I hope the experts here can give me some guidance. I'm a newbie, 555555.
Thanks in advance
Floor 2 Posted 2003-07-14 00:00 ·  中国 河南 郑州 联通
初级用户
Credits 180
Posts 25
Joined 2003-07-11 00:00
23-year member
UID 6759
Gender Male
Status Offline
10 F0$="1.txt" :rem --------------------- the filename you want to back up
20 P0$="C:\abc\":rem -------------------- your original directory name
30 P1$="C:\abc\":rem -------------------- the directory where you want to put the backup file (here it is the same)
40 M$=MID$(DATE$,1,2):rem --------------- get month
50 D$=MID$(DATE$,4,2):rem --------------- get day
60 Y$=MID$(DATE$,7,4):rem --------------- get year
70 S$=Y$+M$+D$:rem ---------------------- generate the backup file by year, month, and day
80 F1$=S$+".txt":rem -------------------- add the extension to the backup filename (here it is .txt)
90 C$="copy "+P0$+F0$+" "+P1$+F1$:rem --- generate the DOS command string
100 SHELL C$:rem ------------------------ use SHELL to execute the DOS command string
110 END

Save it with the filename Sav-DAY.BAS

When using it, just add the following command to the batch file!
BASIC.EXE Sav-DAY.BAS
Floor 3 Posted 2003-07-14 00:00 ·  中国 河南 郑州 联通
初级用户
Credits 180
Posts 25
Joined 2003-07-11 00:00
23-year member
UID 6759
Gender Male
Status Offline
SLBBS was debugged under WIN98
Forum Jump: