Search code examples
shellcygwinclearcase

Clearcase Multi-file rename


I have a large number of files in a ClearCase directory structure, and I need to go through and change all "makefile" to "Makefile". I'm thinking some combination of the find . -name makefile command with an exec flag, but I'm having a hard time coming up with the exec command. The cleartool mv command does not automatically check out the directory, so I need to check that out and then do the mv. But as far as I can tell, the only thing I have to work with is the %CLEARCASE_PN% symbol, which gives me the full pathname. So I need to parse the directory out from that. I'm hoping someone who's better with the shell than me can come up with the right command quicker than I can puzzle it out.

I have cleartool, Windows cmd, and Cygwin to work with here.


Solution

  • I guess that you have bash in your cygwin environment. If you do you can write a small bash script using this answer to a previous question into something as:

    #!/bin/bash
    FILE=$1
    DIR_NAME=$( dirname $FILE )
    FILE_NAME=$( basename $FILE )
    
    #checkout directory $DIR_NAME with whatever the cleartool command is
    #rename with cleartool $DIR_NAME/$FILE to $DIR_NAME/new_name
    
    /usr/atria/bin/cleartool checkout -nc $DIR_NAME; 
    /usr/atria/bin/cleartool mv $DIR_NAME/$FILE_NAME $DIR_NAME/Makefile;
    

    Then call the script with:

    find . -name orig_name -exec myscript.sh {} \;
    

    Warnings:

    • a directory already checked-out will trigger an error message when checked-out again (can be ignored)
    • you will have to check-in all the directories checked-out during this process, otherwise nobody will see the result of the move (except the ones accessing this current view)