Question: Can anyone help me correct this batch file? I think the issue is in the for / f statement someplace. The objective is to count
Can anyone help me correct this batch file? I think the issue is in the for f statement someplace. The objective is to count the files and subdirectories within a specific directory including hidden ones, however NOT to count any of the files in the subdirectories.
setlocal enabledelayedexpansion
echo.
set p "directoryWhat directory would you like to check?
set "fileCount
set "hiddenFiles
set "visibleFiles
set "dirCount
set "hiddenDirs
set "visibleDirs
for f i in dir a s b directory do
set "attr~ai
set a "fileCount
if attr:~h
set a "hiddenFiles
else
set a "visibleFiles
if attr:~d
set a "dirCount
if attr:~h
set a "hiddenDirs
else
set a "visibleDirs
:: Display message with results
echo.
echo There are a total of fileCount files in the directory directory.
echo Of the fileCount files, hiddenFiles are hidden and visibleFiles are not hidden.
echo.
echo There are a total of dirCount directories in the directory directory.
echo Of the dirCount directories, hiddenDirs are hidden and visibleDirs are not hidden.
echo.
pause
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
