Replacing characters in a directory structure


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing characters in a directory structure
# 1  
Old 10-31-2002
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.
# 2  
Old 10-31-2002
looks like DOS question.

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.

Smilie
# 3  
Old 11-01-2002
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
# 4  
Old 11-01-2002
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! Smilie
# 5  
Old 11-01-2002
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

2. Shell Programming and Scripting

Create Directory structure

Hello ; ) again Now I have my file like this : DIR2/DIR3 DIR2 DIR2/DIR3/DIR4/DIR5 I am looking for help to create a loop that will create the directory structure. I need something like this : If "DIR2" does not exist > Create IF "DIR2" exist already > check if onther "DIR"... (5 Replies)
Discussion started by: Aswex
5 Replies

3. Solaris

Question about directory structure

I have a Solaris 9 system and was trying to familiarize myself with how the filesystem is laid out. I was wondering what the following directories were for (legacy, some administrative reason, etc) The reason I ask about these specific directories is that they have executables with the... (4 Replies)
Discussion started by: thmnetwork
4 Replies

4. Shell Programming and Scripting

printing a directory structure

Hey everyone I am just trying print a directory structure but I am not getting the desired output. I am using AIX. Script : input file contains : TNP\\ECOM\\test\\1 input_file=folders.txt cat $input_file | while read line do echo $line done (3 Replies)
Discussion started by: rocker_me2002
3 Replies

5. UNIX for Dummies Questions & Answers

Directory Structure

Hi... I have a directory which has multiple directories and sub directories inside... what command should i use to get a list of all these directories, without the filenames.... (2 Replies)
Discussion started by: saharookiedba
2 Replies

6. UNIX for Dummies Questions & Answers

Copying with directory structure

Hi, I need to copy a set of directories along with all sub directories and files from one unix box to another. Any ideas? cnfsed (4 Replies)
Discussion started by: Cnfsed
4 Replies

7. Shell Programming and Scripting

Need help in Directory Structure

I have writen the following code to show the dirctory structure. Can any body help me for using the recursive function in this code? echo "-(0)" echo "$HOME-(1)" cd ~ set * for i in `ls $HOME` do if then echo ".....${i}" cd... (5 Replies)
Discussion started by: murtaza
5 Replies

8. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

9. UNIX for Dummies Questions & Answers

Copying a Directory Structure to a new structure

Hi all Is it possible to copy a structure of a directory only. e.g. I have a file with the following entries that is a result of a find :- /dir1/dir2/file.dbf /dir1/dir2/dir3/file1.dbf /dir1/file.dbf I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Discussion started by: jhansrod
8 Replies
Login or Register to Ask a Question