`Felix` Posted March 13, 2005 Share Posted March 13, 2005 Hello there,I want to do a directory listing and then echo only the directoriesthat do not match the list i provide... i have been working with thefollowing code, but i have been unable to get the right syntax... helppls.@echo offclsset TmpPath=thetmpset tlist="sub1" "sub2" "sub 5" "sub 8" "sub 9"rem for /f "usebackq delims= tokens=1,2*" %%i in (`%twant%`) do if /iNEQ %%i echo %%icall:test "sub1":testfor /f "usebackq delims= tokens=1,2" %%i IN (`dir /ad /b"%TmpPath%\%~1"`) DO IF /i "%%i" NEQ "%~1" echo %%iI have thetmp directory setup and then under that folder i have sub1 -15. The final cost would then list all folder accept for sub1,sub2,sub5,sub 8 and sub9This works well below, however i am having problems with checking against my list.for /f "usebackq delims= tokens=1,2" %%i IN (`dir /ad /b"%TmpPath%\%~1"`) DO IF /i "%%i" NEQ "%~1" echo %%iall responses very appreciated Link to comment Share on other sites More sharing options...
IcemanND Posted March 14, 2005 Share Posted March 14, 2005 We really have to stop meeting this way.@echo offsetlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONclsset TmpPath=.set tlist="sub1" "sub2" "sub 5" "sub 8" "sub 9"SET fulllist=for /d %%i IN (*) DO set fulllist=!fulllist! "%%i"for %%j IN (%tlist%) do call set fulllist=%%fulllist:%%j=%%for %%k IN (%fulllist%) DO echo %%~k Link to comment Share on other sites More sharing options...
`Felix` Posted March 14, 2005 Author Share Posted March 14, 2005 We really have to stop meeting this way.@echo offsetlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONclsset TmpPath=.set tlist="sub1" "sub2" "sub 5" "sub 8" "sub 9"SET fulllist=for /d %%i IN (*) DO set fulllist=!fulllist! "%%i"for %%j IN (%tlist%) do call set fulllist=%%fulllist:%%j=%%for %%k IN (%fulllist%) DO echo %%~k<{POST_SNAPBACK}>Ice you are right we will have to stop meeting this way The code works well - couple of questions...1. If i want to add as a default say "sub0" but i don't want to have it in tlist var (want to have it in the code as default) where and how would i put it?2. I have been playing with this code below? Do you think that would be a better "cleaner" option and if so, any idea on how i would incorporate the list?DIR "%TmpPath%" /AD /B | FINDSTR /R /V /I /C:"Common Files" /C:"sub0" /c:"sub1" /c:"sub2" /c:"sub 5" /c:"sub 8" /c:"sub 9"So in this i have "common files" and "sub0" that will always been there and the rest will be variable based on the contents of %tlist%Thanks very much for all you help - it has been invaluable! Link to comment Share on other sites More sharing options...
IcemanND Posted March 14, 2005 Share Posted March 14, 2005 To add defaults: (See second FOR statement)@echo offsetlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONclsset TmpPath=.set tlist="sub1" "sub2" "sub 5" "sub 8" "sub 9"SET fulllist=for /d %%i IN (*) DO set fulllist=!fulllist! "%%i"for %%j IN ("SUB0" "COMMONFILES" %tlist%) do call set fulllist=%%fulllist:%%j=%%for %%k IN (%fulllist%) DO echo %%~kYour way is cleaner but harder to pass the list: (one way)set tlist=/c:"sub1" /c:"sub2" /c:"sub 5" /c:"sub 8" /c:"sub 9"DIR /AD /B | FINDSTR /R /V /I /C:"Common Files" %tlist%another way: (limited to 9 sub directories)set tlist=/c:"sub1" /c:"sub2" /c:"sub 5" /c:"sub 8" /c:"sub 9"call:continue %tlist%goto:end:continueDIR /AD /B | FINDSTR /R /V /I /C:"Common Files" %1 %2 %3 %4 %5 %6 %7 %8 %9:endOne last option:setlocal ENABLEDELAYEDEXPANSIONset tlist="sub1" "sub2" "sub 5" "sub 8" "sub 9"for %%j IN ("SUB0" "COMMONFILES" %tlist%) do set switchlist=!switchlist! /C:%%jDIR /AD /B | FINDSTR /R /V /I /C:"Common Files" %switchlist% Link to comment Share on other sites More sharing options...
`Felix` Posted March 15, 2005 Author Share Posted March 15, 2005 thanks for your help Ice Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now