C
Charles Theodore
Hello to all,
Want to be able to browse in \\s45r\files\msi\ share to parse all the
directory structure the presence of a directory named "programs",
verify if it is empty and output the result on a text file with the
UNC path when the dir are empty.
Here are some part of source code grabbed from this forum, but i'm not
strong enough in batch to assemble all the part. Thanks you to all.
Charles
::========================= F_Empty.cmd =============================
@echo off&setlocal ENABLEEXTENSIONS
set dir=\\s45r\files\msi
set log=logfile.log
for /f "delims=" %%A in ('dir/B/S/AD "%dir%"') do (
find "programs" & if exist "%%A\programs" call :check "%%A"
)
goto :eof
:check
:: check if directory exists
dir %dir% /ad 2>nul >nul||(echo/Dir not exist&goto :EOF)
:: check if directory has no files
set f=0&for /f %%a in ('dir %dir% /a-d/b 2^>nul') do set/a f+=1
if %f% NEQ 0 (echo/Dir has files) else (echo/Dir has no files)
:: check if directory has no subdirectorys
set d=0&for /f %%a in ('dir %dir% /ad/b 2^>nul') do set/a d+=1
if %d% NEQ 0 (echo/Dir has dirs) else (echo/Dir has no subdirs)
:: check if directory is completely empty
if 1%f%%d% NEQ 100 (echo/Dir not empty) else (echo/Dir is empty)
:log
???
Want to be able to browse in \\s45r\files\msi\ share to parse all the
directory structure the presence of a directory named "programs",
verify if it is empty and output the result on a text file with the
UNC path when the dir are empty.
Here are some part of source code grabbed from this forum, but i'm not
strong enough in batch to assemble all the part. Thanks you to all.
Charles
::========================= F_Empty.cmd =============================
@echo off&setlocal ENABLEEXTENSIONS
set dir=\\s45r\files\msi
set log=logfile.log
for /f "delims=" %%A in ('dir/B/S/AD "%dir%"') do (
find "programs" & if exist "%%A\programs" call :check "%%A"
)
goto :eof
:check
:: check if directory exists
dir %dir% /ad 2>nul >nul||(echo/Dir not exist&goto :EOF)
:: check if directory has no files
set f=0&for /f %%a in ('dir %dir% /a-d/b 2^>nul') do set/a f+=1
if %f% NEQ 0 (echo/Dir has files) else (echo/Dir has no files)
:: check if directory has no subdirectorys
set d=0&for /f %%a in ('dir %dir% /ad/b 2^>nul') do set/a d+=1
if %d% NEQ 0 (echo/Dir has dirs) else (echo/Dir has no subdirs)
:: check if directory is completely empty
if 1%f%%d% NEQ 100 (echo/Dir not empty) else (echo/Dir is empty)
:log
???