• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

script to change file name

Hi,

on Solaris 10, with tcsh

I have 1000 files which are named something like:
IND_"SW"."YELOW_IDX1"_1280.sql

I am looking for a tcsh script to rename them without the quotes:
IND_SW_YELOW_IND1_1280.sql

Many thanks
0
peledc
Asked:
peledc
1 Solution
 
yuzhCommented:
Why do you want to use csh/tcsh for script?
For shell scripting you should use sh/ksh, it is a lot easy to do things than csh/tcsh.

please have a look at "Csh Programming Considered Harmful":
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Here's a ksh script can do the job for you:

#!/bin/ksh
cd /path-to/mydir   # replace it the the real dir name in your system

for file in `ls *\"*` ; do
    newname=`echo $file | tr -d \"`
    mv $file $newname
done

echo " Job done !"
exit
# End of script
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now