views:

382

answers:

1

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.

+3  A: 

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)
David Rodríguez - dribeas
Perfect! In case anyone's wondering, the cleartool commands are:cleartool checkout -nc $DIR_NAME;cleartool mv $DIR_NAME/$FILE_NAME $DIR_NAME/Makefile;
mbyrne215
Anyone knows how to edit this answer to add the cleartool commands into the sample code above? In other posts I have an edit option, but not here. Maybe because it is accepted as the answer?
David Rodríguez - dribeas
cleartool commands added to your answer. Let me know if you want me to edit anything else.
VonC
Thanks, I just wanted to add the feedback from the original post so it would be easier on future readers. Thanks a log.
David Rodríguez - dribeas