Command to find all view private files in the current directory recursively
Asked Answered
K

6

30

What is the clearcase Command to find all view private files in the current directory recursively?

Kamin answered 5/10, 2011 at 5:35 Comment(0)
S
35

The usual commands are based on cleartool ls:

  • ct lsprivate: but it is only for dynamic views, not snapshot views
  • ct ls -rec -view_only: at least, it works in both snapshot and dynamic views

However both list also your checked-out files.

If you want only the private files, ie skipping the hijacked/eclipsed/checked-out and symlinks, you need to filter those out.

In Windows, that would be:

for /F "usebackq delims=" %i in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do @echo "%i"

In Unix:

cleartool ls -rec | grep -v "Rule:" | grep -v "hijacked" | grep -v "eclipsed" | grep -v "-->" | xargs echo
Stacte answered 5/10, 2011 at 5:40 Comment(1)
For ct lsprivate, specifying the -other option will leave out checked-out files. EDIT: Never mind, Otzen already said that in his answer 2 years ago.Gubernatorial
C
5

In case it helps anyone else reading this question here is VonC's windows solution with a couple of minor changes to run as a windows script:

@echo off
setlocal
for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do @echo "%%A"

Replace @echo with rmdir /S /Q and del /F to do the actual deletions as described here. So the final script is:

@echo off
setlocal
for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do rmdir /S /Q "%%A"
for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do del /F "%%A"

If you save as a .bat file under the element of the view you are cleaning from, the script will clean up by deleting itself as well :-)

Coulombe answered 26/11, 2013 at 23:20 Comment(0)
S
3

I amended the version by @MilesHampson since this returned too many results for me and, I want to run this as a batch file.

My new files won't be in the debug or obj folder and as such, I don't need to see any results for those folders... I'm also only working on C#. So that's all I need to see.

@echo off
setlocal

@echo Searching, please wait as this can take a while...

for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->" ^| find /V "obj" ^| find /V "debug"`) do  ( 
  if "%%~xA"==".cs" echo %%A
  )
)

@echo === === === === === Search Complete === === === === === === 

pause

Create a bat file with the above, drop it into your root project folder and run it. It will display those not in source control.

Stannwood answered 4/2, 2014 at 13:43 Comment(0)
M
3

In case it helps anyone else reading this question, here is VonC's Unix solution with a couple of minor changes to run under Cygwin on Windows.

In Cygwin:

cleartool ls -rec | grep -v "Rule:" | grep -v "hijacked" | grep -v "eclipsed" | grep -v -- "-->" 

The Cygwin line is similar to the Unix given by VonC, but note the double-dash on the last grep is needed (and the xargs is not needed).

Mesosphere answered 4/2, 2014 at 20:49 Comment(0)
U
2
ct lsprivate -other 

Would also filter out checked-out files

ct lsprivate -co : list all checked-out files

ct lsprivate -do : list all derived object files

ct lsprivate -other : list all other private files

Underhill answered 24/9, 2013 at 13:33 Comment(0)
P
0

I followed all above solutions and it is great command. I had some more requirements that were not covered above so I modified script little more with below additional points

  1. Excluded batch file from list (otherwise current batch file also coming in list)
  2. Removed Directory from list as generally I am interested in file

  3. Specially for java developer, excluded target folder and jar files as they are not generally checked in

  4. Removed .classpath, .project and .settings folder which is specific to Eclipse (if they are same level as project/modules)

    @echo off
    setlocal
    
    @echo.
    @echo Searching, please wait as this can take a while...
    @echo.
    for /F "usebackq delims=" %%i in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->" ^| find /V ".settings" ^| find /V "jar" ^| find /V "keep" ^| find /V "target" ^| find /V ".classpath"  ^| find /V ".project" ^| find /V "%~n0" `) do ( if not exist %%i\* @echo "%%i")
    
    @echo.
    @echo === === === === === Search Complete === === === === === === 
    @echo.
    @echo.
    
    pause
    
Pow answered 9/8, 2017 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.