Open SaiSakthi18 opened 1 month ago
@echo off setlocal enabledelayedexpansion
:: Check if folder path is provided if "%~1"=="" ( echo Please provide the folder path. exit /b )
:: Set the target folder from the first argument set "target_folder=%~1"
:: Define the output file set "output_file=output.csv"
:: Write the header for the CSV file echo Folder Name,File Count > %output_file%
:: Loop through each folder inside the target folder for /d %%F in ("%target_folder%*") do ( set "folder=%%~nxF"
:: Count files in the folder (non-recursive)
set "count=0"
for %%X in ("%%F\*.*") do (
set /a count+=1
)
:: Write the folder name and count to the CSV file
echo !folder!,!count! >> %output_file%
)
echo Done! The file counts are saved in %output_file%
@echo off setlocal enabledelayedexpansion
:: Check if folder path is provided if "%~1"=="" ( echo Please provide the folder path. exit /b )
:: Set the target folder from the first argument set "target_folder=%~1"
:: Define the output file set "output_file=output.csv"
:: Write the header for the CSV file echo Folder Name,File Count > %output_file%
:: Loop through each folder inside the target folder for /d %%F in ("%target_folder%*") do ( set "folder=%%~nxF" set "count=0"
)
echo Done! The file counts are saved in %output_file%