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-03 04:36
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to do CD copying programs? View 2,142 Replies 18
Original Poster Posted 2007-01-11 21:59 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
1. After inserting the CD, run this program, which can copy all the contents on the CD into one path on the hard disk.
2. Automatically check the newly copied things in this path and delete all *.bak files.
3. Generate a txt file or web page file that records the capacity of the just - copied things (precise to Mb), the total number of files. It would be even better if there is something like a tree - like structure to display the contents inside.

Thank you, any expert brother, help me out.

[ Last edited by namejm on 2007 - 1 - 11 at 05:03 PM ]
Floor 2 Posted 2007-01-12 01:41 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
My CD drive is I, and the files are copied to h:\5.

The code is as follows:
@echo off
md h:\5
xcopy/s/e/q i:\*.* h:\5>nul&cd/d h:\5
if exist *.bak del *.bak
for /f "tokens=1-4 delims= " %%i in ('dir/s ^|find "文件"') do set a=%%i&set b=%%j&(if not "%%k"=="" set/a size=%%k/1048576)
echo %a%%b% %size%MB>c:\1.txt

for /f "skip=2 delims=" %%i in ('tree /f h:\5') do @echo. %%i>>c:\1.txt
start c:\1.txt



The display result is:
8 files  30MB
H:\5
│ DI-604.mbd
│ autorun.exe
│ autorun.inf

├─Acrobat
│ AdbeRdr60_enu_full.exe

├─Manual
│ di604_man_revx_ger_161204.pdf
│ di604_manual_205.pdf

└─Quick Installation Guide
di-604_manual_203_DE.pdf
di604_QIG_205.pdf


[ Last edited by ccwan on 2007-1-12 at 01:49 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lxmxn +4 2007-01-12 01:54
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 3 Posted 2007-01-12 01:54 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Your batch script is quite good, add points.

Floor 4 Posted 2007-01-12 05:42 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
Thanks, moderator. I will correct it as soon as possible.
Thanks, brother on the 2nd floor. But it seems that the capacity display is incorrect. I saw from the file properties that it is 290MB, but in 1.txtl it is 304M. Why?
Also, if bak is a hidden file, can it be deleted?

[ Last edited by tuesposo on 2007-1-11 at 04:45 PM ]
Floor 5 Posted 2007-01-12 05:53 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Capacity is just an approximate number and won't be too accurate. Otherwise, you can try changing it to size=%%k/1049000 to see if it works. The del command can be used with parameters, and del/a/f/q should be sufficient.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 6 Posted 2007-01-12 05:55 ·  中国 江西 赣州 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
This is not bad for making an index!!
Floor 7 Posted 2007-01-12 05:55 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
Thanks. Also, can the file name not be 1.txt? The txt file name should be the time of the copy day, like 2006-05-13.txt. It would be better if it can be precise to the time, like 2006-05-13(16:52).txt. Can this function be available?
Floor 8 Posted 2007-01-12 06:04 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
There are many ways in the forum about creating files named with date and time. You can search for it.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 9 Posted 2007-01-12 21:44 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
The time issue has been resolved, but how to display the capacity? I mean the file capacity shown when you right-click the mouse, not the file capacity converted from bytes.
Floor 10 Posted 2007-01-12 21:55 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Originally posted by tuesposo at 2007-1-12 21:44:
The elder brother, the time problem is fixed. But how to display the capacity? I mean the file capacity shown when right-clicking the mouse, not the file capacity converted from bytes.


This sentence is quite hard to understand.
Actually, the capacity in the right-click properties is also based on the byte as the basic unit. The so-called MB is also calculated from bytes.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 11 Posted 2007-01-12 22:09 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
Brother, I added a pause at the end of the program, and the program doesn't close automatically. Why do I get the following content?
Invalid number. Numeric constants can only be decimal (17), hexadecimal (0x11) or octal (021). Which line is the problem?
Floor 12 Posted 2007-01-12 22:36 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
I think it's because of floating - point operation problems. But it doesn't affect use and display, and it can be shielded.
set a=%%i&set b=%%j&(if not "%%k"=="" set/a size=%%k/1048576)


The above sentence is changed to this:
set a=%%i&set b=%%j&(if not "%%k"=="" set/a size=%%k/1048576) 2>nul
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 13 Posted 2007-01-12 22:48 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
Gaga, the problem is solved, :P:D:lol: Thank you, but there's still a small problem. I divided the number of bytes by 1048576, and the result is also incorrect. There's a difference of more than 10MB. Could it be that the number of bytes is incorrect?
Floor 14 Posted 2007-01-12 22:51 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Then, how many bytes is your file exactly? Have you tried using 1049000 as I mentioned on the 5th floor? After trying, please post the result for us to see, okay?
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 15 Posted 2007-01-12 22:56 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
I've tried everything.

The file properties show 304,880,027 bytes, and the size is 290M. Dividing 304,880,027 by 1048576 gives 290.756.

But 1.txt says 304Mb, and the number of files is the same as in the file properties, which is 879.
Forum Jump: