Search code examples
batch-fileclearcase

Batch file to delete ClearCase view-private directories and files


After searching on this forum, I finally got down to these 2 command-lines below that I run in a batch file to delete ClearCase view-private directories and files in my snapshot view.

REM First delete view-private directories
for /F "usebackq delims=" %%i in (`cleartool ls -r ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do ( if exist "%%~i\" ( rmdir /S /Q "%%i" ) )

REM And then delete view-private files
for /F "usebackq delims=" %%i in (`cleartool ls -r ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do ( if not exist "%%~i\" ( del /S /Q /F /A:H "%%i" ) )

However, I get these errors from time to time:

Could Not Find C:\Source\Folder\FileA.log
Could Not Find C:\Source\Folder\FileB.log
Could Not Find C:\Source\Folder\SubFolder\FileC.pbl

The files are view-private files and they do exist at the provided location. But it looks like the batch file cannot "see" to delete them. What am I doing wrong?


Solution

  • I updated the delete command to remove the switches and my batch file was finally able to find the view-private files and delete them.

    REM And then delete view-private files
    for /F "usebackq delims=" %%i in (`cleartool ls -r ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do ( if not exist "%%~i\" ( del "%%i" ) )