Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming files

Status
Not open for further replies.

teser

Technical User
Mar 6, 2001
194
US
How would I rename many files (over 100 total) in a directory.
Example of my files:
file1.word.1
file2.word.2
file3.word.3

I want them to be named:
File1_word_1
File2_word_2
File3_word_3

My goal is to get rid of the periods and put in underline bars for each
file name.

Here is my script that didnt work->
#!/bin/ksh
for file in wer
do
mv *.*.* _._._
done
 
here is that does work (i hope)
#!/bin/ksh
for file in *.*.*
do
echo mv $file `echo $file|awk '{ gsub( "\.", "_")
print toupper( substr( $1, 1, 1)) substr( $1, 2)}' `
done

succes Gregor Gregor.Weertman@mailcity.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top