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-06-21 05:10
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to execute commands based on the size of a file? View 2,509 Replies 13
Original Poster Posted 2006-12-03 01:51 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
Ask the expert:
How can I execute batch processing commands according to the size of a certain (some files)?
Description: The files only refer to txt format.
Floor 2 Posted 2006-12-03 02:05 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Floor 3 Posted 2006-12-03 02:11 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
Originally posted by vkill at 2006-12-2 13:05:
%%~zi

:(;)Don't understand??
I don't know if I can be more detailed, I've only been learning p for a few days?
Floor 4 Posted 2006-12-03 02:16 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Just run the following code to know how to do it:

@echo off
for %%i in (test.txt) do echo The size of test.txt is %%~zi bytes
pause
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2006-12-03 02:26 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
Thanks everyone~~

Without realizing it, there's another question~~ I wonder if the moderator will let me change the title?~~

Ask: How did you know about that %%~zi?? I learned P in the CMD by using xxxx/?
Floor 6 Posted 2006-12-03 02:48 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
If I want to know the files larger than 104K under the C drive~~Everyone, take a look at where my command is wrong??
I ran it on my machine and it said the system couldn't find the file "*.*"

@echo off
for /f %%i in (c:\*.*) do if "%%~zi" GTR "140" echo %%i
pause
Floor 7 Posted 2006-12-03 03:04 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
```
for %%i in (c:\*.*) do if "%%~zi" GTR "140" echo %%i
```

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 8 Posted 2006-12-03 03:25 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
Okay, thank you first~~~
I don't know why after adding "/F" it...
Also, this seems to be only for files under C: and didn't enter the folder under C: I don't know if it can be modified to execute in the entire disk~~
Floor 9 Posted 2006-12-03 03:31 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 10 Posted 2006-12-03 03:56 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
OK, got it. Thanks. Let me see if I can name them for them....
Floor 11 Posted 2007-05-07 19:05 ·  中国 广东 中山 电信
初级用户
★★
Credits 127
Posts 62
Joined 2007-04-19 12:43
19-year member
UID 85744
Gender Male
Status Offline

─────────────────── 版务记录 ────────────────────
Executor: bjsh
Description: Spamming
Punishment: Since it is a new member of the forum, no punishment is temporarily given; if found again, it will be severely punished
─────────────────── 版务记录 ────────────────────

Learned something!

[ Last edited by bjsh on 2007-5-7 at 08:21 PM ]
Floor 12 Posted 2008-03-29 09:37 ·  中国 香港 中信国际电讯
新手上路
Credits 8
Posts 4
Joined 2008-03-27 21:15
18-year member
UID 114215
Gender Male
Status Offline
Thanks, just needed this batch script
Floor 13 Posted 2008-03-29 11:25 ·  中国 上海 电信
新手上路
Credits 2
Posts 1
Joined 2008-03-29 11:05
18-year member
UID 114334
Gender Male
Status Offline
A bit profound, can't understand it to say
Floor 14 Posted 2008-03-30 03:52 ·  中国 浙江 嘉兴 平湖市 电信
初级用户
★★
Credits 157
Posts 67
Joined 2007-05-13 11:03
19-year member
UID 88378
Gender Male
Status Offline
@echo off
for /r c:\ %%i in (*.exe) do if "%%~zi" GTR "106496" echo %%i
pause
Forum Jump: