Change blank space in Filename

Change blank space in Filename

Post by oaklande » Thu, 31 May 2001 20:30:04



I want to change many file names with blank spaces and replace
blank spaces with underbar character.
Example:
File One   change to   File_One
File Two   change to   File_Two

Here is my script:
for name in `ls *" "*`
do
new=`echo $name | tr " " "_"`
mv $name $new
echo $new
done    

Please advise what is wrong with my script that isnt
working.

--
Posted via CNET Help.com
http://www.help.com/

 
 
 

Change blank space in Filename

Post by Rafael Garcia-Suar » Thu, 31 May 2001 20:39:49


oaklander wrote in comp.unix.solaris:

Quote:} I want to change many file names with blank spaces and replace
} blank spaces with underbar character.
} Example:
} File One   change to   File_One
} File Two   change to   File_Two
}
} Here is my script:
} for name in `ls *" "*`
} do
} new=`echo $name | tr " " "_"`
} mv $name $new

The problem is here. $name expands to several words. Try
  mv "$name" $new

Quote:} echo $new
} done    

--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/

 
 
 

1. Changing Filenames with Blank spaces.

I want to change many file names with blank spaces and replace
blank spaces with underbar character such examples:
File One   change to   File_One
File Two   change to   File_Two

Here is my script:
for name in `ls *" "*`
do
new=`echo $name | tr " " "_"`
mv $name $new
echo $new
done    

Please advise what is wrong with my script that isnt
working.

--
Posted via CNET Help.com
http://www.help.com/

2. Xalan on AIX Core Dumps due to Illegal Instruction

3. Using tar with filenames that have blank spaces

4. 3Com ADSL HomeConnect PCI Modem

5. Blank space in Filename

6. Writing NIS+ FAQ, want info.

7. FYI: Change blank to Tab but keep spaces between quotation marks

8. Lame hack attempt

9. script change filename with space to underscore

10. How to change Windows-compliant filenames to Unix filenames

11. Change Upper case filename to lower case filename

12. filenames with blanks, newlines, punctuations, and escape characters.

13. How to create filename with date and not have blanks