中国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-12 18:28
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS学习入门 & 精彩文章 (教学室) » [Help] Can files be backed up automatically by date? Many thanks~
Printable Version  708 / 2
Floor1 Style Posted 2003-07-01 00:00
初级用户 Posts 1 Credits 103
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
Floor2 slbbs Posted 2003-07-14 00:00
初级用户 Posts 25 Credits 180
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
Floor3 slbbs Posted 2003-07-14 00:00
初级用户 Posts 25 Credits 180
SLBBS was debugged under WIN98
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023