Replacing characters in a directory structure

I have a directory structure that contains "()". I need to recursivly replace the "(" with an "" and remove the ")". Can I write a script to:
Read -R C:\VCE
If "(" exitsts replace with "
"
elseif ")" exists, delete.

It would really help if you could tell us what OS you are using. Also, are you saying that your directory names have () in them and you want to change it to _ for each occurrence?

However, it looks like you are giving an example of a PC directory structure. This is a UNIX forum not for DOS or Windows questions.

:wink:

You're right, it does look like a dos question. Sorry about that. Lets say read /VCE recursively on an HP-UX 11 workstation. and change every occurence of "(" to an "_" and remove every occurence of ")". I need it to read just the directory and sub-directory names, but not any of the files in the directories.

ie change /VCE/Dir(1) to /VCE/Dir_1

I am not sure that there is any command that can recursively do this.

You will have to write a script to capture your directories to a file and then read them into the script to change them beginning at the top of the directory tree working downward.

I would use find . -name "(" > file.out to capture the directories in order.

Have fun! :smiley:

You might want to add "-type d" onto the find command that Kelam stated to limit the search to directories only - which is what you stated you wished to do.