From 787d78e91ad1273381b9e832947d4cf3289941a8 Mon Sep 17 00:00:00 2001 From: stansmith Date: Wed, 28 Jan 2009 17:12:28 +0000 Subject: [PATCH] [WinOF] learned about .bat for() loops & default delimiters with folder name which contain spaces (say if you make a copy of a folder). The default delimiters & allow a filename like 'c:\openIB\gen1\trunk\ulp\ipoib - Copy(2)\objfre_wlh_x86' to be returned as 'c:\openIB\gen1\trunk\ulp\ipoib' suitable for removal - not the intent. git-svn-id: svn://openib.tc.cornell.edu/gen1@1912 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/etc/clean-build.bat | 45 +++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/trunk/etc/clean-build.bat b/trunk/etc/clean-build.bat index e0cb9400..80beb92b 100644 --- a/trunk/etc/clean-build.bat +++ b/trunk/etc/clean-build.bat @@ -1,25 +1,35 @@ @echo off +setlocal + rem usage: clean-build {scan} -rem no args - remove build specific files: *_wxp_* *_wnet_* *_wlh_* -rem arg1 = scan - then report matched folders & files - no delete. +rem no args - remove build specific folder & files: *_wxp_* *_wnet_* *_wlh_* +rem arg1 != "" - then report matched folders & files - no delete. -setlocal set T=%TEMP%\flist.txt rem delete OS flavor {wlh,wxp,wnet} specific build files to ensure a clean build +rem The story behind the for loop need for the fake 'delims=,' is the need to +rem override the default delimiters of & , anything but +rem or . Problems occur with a folder name like +rem 'c:\svn\trunk\ulp\ipoib - copy(2)\objfre_wlh_x86' as the default delimiters +rem in for loop file read return 'c:\svn\trunk\ulp\ipoib', bad juju. + rem check/remove directories -for %%d in ( _wxp_ _wnet_ _wlh_ ) do ( +for %%d in ( _wlh_ _wnet_ _wxp_ ) do ( + echo Folder Scan for *%%d* dir /B /S /A:D *%%d* > %T% 2>&1 if ERRORLEVEL 1 ( del /Q/F %T% ) else ( - for /f %%f in ( %T% ) do ( - if "%1" == "" ( - rmdir /S /Q %%f 1>nul - ) else ( - echo found %%f + for /f "delims=," %%f in ( %T% ) do ( + if EXIST "%%f" ( + if "%1" == "" ( + rmdir /S /Q "%%f" 1>nul + ) else ( + echo found "%%f" + ) ) ) del /Q/F %T% @@ -28,20 +38,23 @@ for %%d in ( _wxp_ _wnet_ _wlh_ ) do ( rem check/remove files -for %%d in ( _wxp_ _wnet_ _wlh_ ) do ( +for %%d in ( _wlh_ _wxp_ _wnet_ ) do ( + echo File Scan for *%%d* dir /B /S *%%d* > %T% 2>&1 if ERRORLEVEL 1 ( del /Q/F %T% ) else ( - for /f %%f in ( %T% ) do ( - if "%1" == "" ( - del /F /Q %%f 1>nul - ) else ( - echo found %%f + for /f "delims=," %%f in ( %T% ) do ( + if EXIST "%%f" ( + if "%1" == "" ( + del /F /Q "%%f" 1>nul + ) else ( + echo found %%f + ) ) ) del /Q/F %T% ) ) - endlocal + -- 2.46.0