We help IT Professionals succeed at work.

script to change file name

peledc
peledc asked
on
Medium Priority
299 Views
Last Modified: 2013-12-27
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
Comment
Watch Question

CERTIFIED EXPERT
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.