批处理清理vc++共工程

@echo off

echo ----------------------------------------------------
echo By ahy
echo Press key to choise delete files or dir ...
echo key 1 for delete temp file by suffix,eg: *.sdf *.obj *.ilk
echo key 2 for delete project's setting files,eg: *.aps *.suo *.opt 
echo key 3 for delete dir, eg: ipch
echo key 4 equal like key1 key2 key3
echo ----------------------------------------------------
echo Press any key to delete all files with ending: 
echo *.aps *.idb *.ncp *.obj *.pch *.tmp *.sbr
echo *.tmp *.pdb *.bsc *.ilk *.res *.ncb *.opt
echo *.suo *.manifest *.dep
echo There are Visual C++ and Visual Studio junk
echo ----------------------------------------------------


:start
:: configuration
set strTempFile=*.res *.idb *.exp *.obj *.pch *.ilk *.sdf *.suo *.log *.tlog *.lastbuildstate *.VC.db *.bsc *.sbr *.tmp *.dep *.pdb
set strProFile=*.aps *.clw *.ncb *.opt *.plg
set strDelDir=ipch Pdb .vs

set delAllFlag=0
set c=
set /p c=[1.del tmpfile 2.del profile 3.del ipch dir 4.del all ignore] 


if "%c%"=="  "  goto :start
if "%c%"==" "  goto :start
if "%c%"=="" (
 goto :start
)

if /i %c%==1 (goto lbDelTempFile)
if /i %c%==2 (goto lbDelProFile)
if /i %c%==3 (goto lbDelDir)
if /i %c%==4 (goto lbDelAllIgnore)
if /i %c%==5 (goto lbTest)
if "%c%"=="q" (exit) else (goto :start)

:lbDelTempFile
echo 【1】begin delete files: %strTempFile%

:splitTempFile

for /f "tokens=1,* delims= " %%i in ("%strTempFile%") do (

    if exist %%i (
    echo exist %%i file delete ...
    del /F /S /Q %%i
    ) else ( 
    echo no exist %%i file, recursion ...
    del /F /S /Q %%i
    )
    set strTempFile=%%j
)
if not "%strTempFile%"=="" goto splitTempFile
if %delAllFlag%==1 (
   set delAllFlag=2
   goto lbDelProFile
)
goto start


:lbDelProFile
echo 【2】begin delete files: %strProFile%
:splitProFile
for /f "tokens=1,* delims= " %%i in ("%strProFile%") do (
    if exist %%i (
    echo exist %%i file delete ...
    del /F /S /Q %%i
    ) else ( 
    echo no exist %%i file, recursion ...
    del /F /S /Q %%i
    )
    set strProFile=%%j
)
if not "%strProFile%"=="" goto splitProFile
if %delAllFlag%==2 (
   set delAllFlag=3
   goto lbDelDir
)
goto start

:lbDelAllIgnore
set delAllFlag=1
goto lbDelTempFile


:lbDelDir
echo 【3】begin delete dir: %strDelDir%

:splitDelDir
for /f "tokens=1,* delims= " %%i in ("%strDelDir%") do (
    if exist %%i (
    echo rm %%i ...
    rd /s /q %%i
    ) else ( 
    echo no exist %%i dir
    )
    set strDelDir=%%j
)
if not "%strDelDir%"=="" goto splitDelDir
goto start



:lbTest
if exist *.ncb (
echo exist ncb file.
) else ( 
echo no exist ncb file!
)

if exist *.ncbs (
echo exist ncbs file.
) else ( 
echo no exist ncbs file!
)

if exist *.ncbl (
echo exist ncbl file.
) else ( 
echo no exist ncbl file!
)

if exist *.lncb (
echo exist lncb file.
) else ( 
echo no exist lncb file!
)

if exist *.sncb (
echo exist sncb file.
) else ( 
echo no exist sncb file!
)
pause>nul
goto start


:end
echo 直接回车了
pause

 

posted @ 2022-04-19 21:02  晨光静默  阅读(39)  评论(0编辑  收藏  举报