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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filename Correction Script

Status
Not open for further replies.

borgware

MIS
Nov 30, 2002
2
US
I am writing a script for correcting filenames created by a Unix
application. Currently I am stuck on filenames containing a character I
cannot determine how to rename in the script. The character is ³, small
superfix 3 in the filename. This was originally saved as a degree symbol; I
would like to change it to "_deg".

Filenames examples:

FLGWN_F_0³
FLGWN_F_180³
FLGWN_F_270³
FLGWN_F_]0³

When the listing is output to a file, the result is:
FLGWN_F_0M-3
FLGWN_F_180M-3
FLGWN_F_270M-3
FLGWN_F_]0M-3


In an extended character map this is #179.

To test:
lsf /parts/iso/FLG* | tr "[\179]" "[\150]"
and
lsf /parts/iso/FLG* | awk '{ sub (/\M_3/, "_"); print }'

Neither does anything to the names.

The desired end result would be to change FLGWN_F_0³ to FLGWN_F_0_deg

Thanks for exploring this with me,

Kirk
 
for file in !ls *i!
do newname=!echo $file|sed -e 's/i$/_qqqqqqq/'!
mv $file $newname
done

NOTA ! are backquote (not in my kb)
-----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
jamisar,

Attempted to do what you suggested with the following results:

> ll FLGWN_F*
-rw-rw-rw- 1 201 users 531 Aug 19 1992 FLGWN_F_0³
-rw-rw-rw- 1 201 users 530 Aug 19 1992 FLGWN_F_180³
-rw-rw-rw- 1 201 users 554 Aug 19 1992 FLGWN_F_270³
-rw-rw-rw- 1 201 users 540 Aug 19 1992 FLGWN_F_90³

> ll FLGWN_F* |sed -e 's/i$/_qqqqqqq/'
-rw-rw-rw- 1 201 users 531 Aug 19 1992 FLGWN_F_0M-3
-rw-rw-rw- 1 201 users 530 Aug 19 1992 FLGWN_F_180M-3
-rw-rw-rw- 1 201 users 554 Aug 19 1992 FLGWN_F_270M-3
-rw-rw-rw- 1 201 users 540 Aug 19 1992 FLGWN_F_90M-3

I failed to mention in the original post that I would like this to work with this character being anywhere in the filename, not just at the end, like my misleading examples.

Thanks for your help,

Kirk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top