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-02 21:39
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Emergency, Get file size in DOS View 1,542 Replies 6
Original Poster Posted 2006-12-27 08:28 ·  中国 四川 成都 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-27 06:16
19-year member
UID 74676
Gender Male
Status Offline
Requirement: There are two files, D:\35.RMVB and D:\35OK.RMVB. Determine whether the sizes of these two files are the same. If the sizes are the same, delete D:\35.RMVB.
Please give help, little brother is very grateful.
[ Last edited by sureme on 2006-12-26 at 07:34 PM ]
Floor 2 Posted 2006-12-27 08:47 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The following is the demonstration code. If it works, just replace the echo statement with the del statement:

@echo off
for %%i in (D:\35.RMVB D:\35OK.RMVB) do call set var=%%var%% %%~zi
call :comp_size %var%
pause
goto :eof

:comp_size
if %1 equ %2 echo The file D:\35.RMVB is about to be deleted
goto :eof


[ Last edited by namejm on 2006-12-26 at 10:05 PM ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2006-12-27 10:33 ·  中国 广西 柳州 电信
初级用户
★★
Credits 168
Posts 78
Joined 2006-12-27 09:58
19-year member
UID 74699
Gender Male
Status Offline
Still a bit unclear...

What does `call set var=%%var%% %%i` mean here? I'm a newbie, sorry.
Floor 4 Posted 2006-12-27 11:07 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by applecy at 2006-12-26 21:33:
Still a bit unclear```

What does call set var=%%var%% %%i mean``? I'm a newbie``Sorry``

  There is a small error here, %%i should be written as %%~zi, and the code on floor 2 has been corrected.

  This sentence means to obtain the byte sizes of the two files and assign them to var.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2006-12-27 12:39 ·  中国 四川 成都 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-27 06:16
19-year member
UID 74676
Gender Male
Status Offline
@echo off
for %%i in (D:\35.RMVB D:\35OK.RMVB) do call set var=%%var%% %%~zi
call :comp_size %var%
pause
goto :eof

:comp_size
if %1 equ %2 del D:\35.RMVB
goto :eof
According to the method you said, a fault occurred during execution. At this time, there should be no del.
I don't know if the moderator has tested it?
Floor 6 Posted 2006-12-27 12:41 ·  中国 四川 成都 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-27 06:16
19-year member
UID 74676
Gender Male
Status Offline
Suggest the moderator to translate the code. I'm a beginner. Thanks in advance
Floor 7 Posted 2006-12-27 12:44 ·  中国 四川 成都 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-27 06:16
19-year member
UID 74676
Gender Male
Status Offline
I made a mistake, and the test was successful
Forum Jump: