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-07-31 23:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help]Modify attributes of all hidden files with for command View 6,160 Replies 32
Original Poster Posted 2007-01-19 09:09 ·  中国 重庆 垫江县 电信
初级用户
Credits 26
Posts 11
Joined 2006-12-16 08:09
19-year member
UID 73697
Gender Male
Status Offline
Originally, I planned to use the for command to delete all *.info files on the disk. The batch commands used were:

for /r %%a in (c: d: e: f:) do tree /f > 1.txt
for %%a in (1.txt) do del *.info

But the *.info files were automatically given the hidden attribute. I don't know how to handle this. I'm asking everyone for help. Thanks!

I initially used for /r %%a in (c: d: e: f:) do attrib -h *.info, but when I ran it, I found that it only modified the info files in the current directory. If I changed it to for /r %%a in (c: d: e: f:) do attrib -h *.info %%a, it would prompt a parameter error. I'm just learning batch processing and don't understand the commands well. Please give me your advice. Thanks again!

[ Last edited by honyfox on 2007-1-18 at 08:16 PM ]
Floor 2 Posted 2007-01-19 09:12 ·  中国 江苏 徐州 电信
高级用户
★★★
前进者
Credits 641
Posts 303
Joined 2007-01-10 02:57
19-year member
UID 76009
Gender Male
Status Offline
The landlord refers to all hidden files, which is said to be very vague. Do you mean you want to remove the attributes of all hidden files on the hard disk, or do you mean to remove the attributes of all hidden files in a partition? Or something else?
我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿!
Floor 3 Posted 2007-01-19 09:16 ·  中国 重庆 垫江县 电信
初级用户
Credits 26
Posts 11
Joined 2006-12-16 08:09
19-year member
UID 73697
Gender Male
Status Offline
Sorry, I accidentally pressed Ctrl+Enter to send it while editing just now, and it wasn't finished yet. Sorry
Floor 4 Posted 2007-01-19 09:34 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
  If it's a Windows XP system, try the following command in the command line?

for /f "skip=1" %i in ('wmic logicaldisk where "drivetype='3'" get caption') do @ del /s/a/f/q %i\*.info
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
htysm +4 2007-01-20 03:24
Floor 5 Posted 2007-01-19 09:50 ·  中国 重庆 垫江县 电信
初级用户
Credits 26
Posts 11
Joined 2006-12-16 08:09
19-year member
UID 73697
Gender Male
Status Offline
It worked, lxmxn is really amazing!
First time I came across the wmic command, just looked it up today and got a good gain again, thanks to lxmxn!
Also, I don't understand the usage of skip here, ask for advice, thanks!
Floor 6 Posted 2007-01-19 09:57 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Because in the for command, skip=n means to ignore the first n lines. And the first line of the output of the wmic command here is "Caption", as shown in the following figure, so here we use "skip=1" to skip the first line and extract the drive letter.

Caption
C:
D:
E:
F:
Floor 7 Posted 2007-01-19 10:08 ·  中国 重庆 垫江县 电信
初级用户
Credits 26
Posts 11
Joined 2006-12-16 08:09
19-year member
UID 73697
Gender Male
Status Offline
Oh, got it, thank you lxmxn ^_^
Floor 8 Posted 2007-01-20 01:30 ·  中国 江苏 连云港 电信
高级用户
★★★
前进者
Credits 641
Posts 303
Joined 2007-01-10 02:57
19-year member
UID 76009
Gender Male
Status Offline
Powerful! I rarely see this command too. There was also once when I saw lxmxn post it, which was to find out how many partitions there are on the computer.
我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿!
Floor 9 Posted 2007-01-20 03:17 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
The DOS forum is really "full of great people"! With just this one line of command, you can traverse all files in all drives on the computer.
Floor 10 Posted 2007-01-20 09:39 ·  中国 江苏 连云港 联通
高级用户
★★★
前进者
Credits 641
Posts 303
Joined 2007-01-10 02:57
19-year member
UID 76009
Gender Male
Status Offline
lxmxn Can you explain the meaning of 'wmic logicaldisk where "drivetype='3'" get caption' for me? I only know that logicaldisk seems to mean logical disk, and I don't know the rest. What kind of command is this? I learned a little bit of DOS basics a long time ago, and I don't seem to have come across this command. I looked at the help, but some things are not very understandable.
我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿!
Floor 11 Posted 2007-01-20 11:15 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
  Re oilio:

The command 'wmic logicaldisk where "drivetype='3'" get caption' here is used to obtain the drive letters of disk drives. Here, where acts as a filter, and drivetype=3 specifies to filter drive types with the code 3. Of course, there are other types, such as 2 for floppy disk drives, 3 for disk drives, and 5 for CD-ROM drives. Since 3 is specified here, the command will give the drive letters of all hard disk drives;

Here, get is a verb. In WMIC, it represents obtaining the property of an alias. Caption is a property of the logicaldisk alias, and its property value is exactly the drive letter of the drive;

Logicaldisk has many other properties, such as DeviceID, DriveType, FreeSpace, ProviderName, Size, VolumeName, etc. These properties can be obtained using the get verb. The specific command help can be obtained by entering the command wmic logicaldisk get /?.

It is recommended that you search for the previous moderator version 3724668's usage of WMIC commands. I am also just learning and don't understand very well. Please forgive any errors, brother.


[ Last edited by lxmxn on 2007-1-19 at 10:24 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
oilio +2 2007-01-21 03:48
Floor 12 Posted 2007-01-21 00:05 ·  中国 广西 梧州 电信
新手上路
Credits 8
Posts 4
Joined 2007-01-10 05:32
19-year member
UID 76025
Gender Male
Status Offline
lxmxn you are so great
that command is so useful
Floor 13 Posted 2007-01-21 03:50 ·  中国 江苏 连云港 电信
高级用户
★★★
前进者
Credits 641
Posts 303
Joined 2007-01-10 02:57
19-year member
UID 76009
Gender Male
Status Offline
Well, okay, thank you, Brother lxmln. I'll go study it. It feels like this command is quite useful. Learned something.
我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿!
Floor 14 Posted 2007-01-21 05:46 ·  中国 广东 梅州 电信
新手上路
Credits 12
Posts 6
Joined 2006-12-18 14:49
19-year member
UID 73872
Gender Male
Status Offline
That's amazing! I haven't seen this command before. I've learned something new again.
Floor 15 Posted 2007-01-22 10:02 ·  中国 湖南 衡阳 电信
中级用户
★★
Credits 322
Posts 144
Joined 2007-01-10 13:00
19-year member
UID 76062
Gender Male
Status Offline
C:\>wmic
'wmic' is not recognized as an internal or external command,
operable program or batch file.
Forum Jump: