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-09 13:45
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Set subdirectories under the root directory and remove the hidden attribute View 722 Replies 1
Original Poster Posted 2008-08-24 11:54 ·  中国 上海 长宁区 电信
高级用户
★★★
Credits 916
Posts 377
Joined 2004-03-08 00:00
22-year member
UID 19523
Gender Male
Status Offline
Need a script to traverse the subdirectories under the current root directory, without going into deeper directories, and use attrib -h to remove the hidden attribute.

Mainly because USB flash drive viruses always set the subdirectories under the root of the USB drive as hidden, so I need a script like this to quickly reset them.

-----------------------
Damn, I didn't look carefully at the dir parameters, so I couldn't get any result all along. This line works now,

for /f %%a in ('dir /b/adh') do attrib -h -s -r "%%a"
pause


Mm, thanks to HAT for the reminder. It should work now. It's been so long, I hardly know how to use for anymore, hehe
for /f "delims=" %%a in ('dir /b/adh 2^>nul') do @attrib -h -s -r "%%a"
pause


[ Last edited by dato on 2008-8-24 at 12:18 PM ]
Floor 2 Posted 2008-08-24 12:13 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
You didn't consider directories with spaces in their names, did you?
Forum Jump: