|
Answer» I'm working on a script that will find all .sql files in all subdirectories and find the permissions for a specific group. I have a BATCH that will CURRENTLY check all files in the CURRENT directory, but I need it to be able to search all subdirectories as well.
Code: [Select]@echo off color 0A
rem Created by SCOTT Dean
if exist !Grants del "!Grants" if not exist !Grants MKDIR !Grants
for %%I in (*.sql) do ( find /n /i "user_group" %%I >> !Grants/User_Grants.txt find /n /i "tech_group" %%I >> !Grants/Tech_Grants.txt find /n /i "config_group" %%I >> !Grants/Config_Grants.txt find /n /i "readonly_group" %%I >> !Grants/ReadOnly_Grants.txt find /n /i "GRANT" %%I | find /v /i "user_group" | find /v /i "tech_group" | find /v /i "config_group" | find /v /i "readonly_group" >> !Grants/Other_Grants.txt echo 1 >> !Grants/i.txt )
find /c "1" !Grants/i.txt > !Grants/i2.txt
for /F "tokens=3*" %%J in (!Grants/i2.txt) do ( echo %%J files checked >> !Grants/User_Grants.txt echo %%J files checked >> !Grants/Tech_Grants.txt echo %%J files checked >> !Grants/Config_Grants.txt echo %%J files checked >> !Grants/ReadOnly_Grants.txt ) del !Grants\i.txt /q del !Grants\i2.txt /q del !Grants.bat This is the current batch I use and I will be modding it to search for a different group realtime_group. But I need it to look in current directory and all subdirectories.
Thanks.C:\test>type grim.bat Code: [Select]@echo off
cd \
echo. > c:\tmp\sql.txt for /f "delims=" %%i in ('dir /s /b *.sql') do ( echo %%~nxi >> c:\tmp\sql.txt ) type c:\tmp\sql.txt find /c /i "sql" c:\tmp\sql.txt cd c:\test Output:
C:\test>grim.bat
InstallCommon.sql InstallMembership.sql InstallPersistSqlState.sql InstallPersonalization.sql InstallProfile.SQL InstallRoles.sql InstallSqlState.sql InstallSqlStateTemplate.sql InstallWebEventSqlProvider.sql UninstallCommon.sql UninstallMembership.sql UninstallPersistSqlState.sql UninstallPersonalization.sql UnInstallProfile.SQL
|