简体   繁体   中英

How can i list all hidden files inside all subdirectories using batch scripting for windows XP?

dir /S /aH doesnt work as it wont delve any deeper inside of unhidden folders.

EDIT: turns out it WAS dir /S /aH just there wasnt any hidden or system files or folders within the non hidden files or folders i was testing on.

This is problematic and the only way I know to solve it is ugly and will give you the result in a "function":

@echo off
setlocal ENABLEEXTENSIONS
goto main

:EnumAllFiles 
FOR /F "tokens=*" %%A IN ('dir /B /S /A:-D-H "%~1" 2^>nul') DO call :%2 "%%~A"
FOR /F "tokens=*" %%A IN ('dir /B /S /A:-DH "%~1" 2^>nul') DO call :%2 "%%~A"
goto :EOF

:mycallback
echo file=%~1
goto :EOF

:main
call :EnumAllFiles "c:\someDirToSearch" mycallback

(This does not tell the mycallback function about folders since you said you wanted files)

Edit: It seems like dir /B /S /aD also works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM