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

Script to change file extension?

Status
Not open for further replies.

nrastogi

Programmer
Jul 19, 2002
52
US
Hi guys,

I am very new to the scripting world.

I have this directory that has 1000's files with the extension .JPG and .jpg as well.

Since, *ix is case sensitive, that is creating a problem for me.

Could you please let me know the script that would go through all the files and change the extension from JPG to jpg.

I am using RedHat 7.3 Linux !

I appreciate your help!

Thanks a lot in advance.

NRastogi




 
I'm sure there's been a similar question posted in Tek-Tips in the past. Have you tried a keyword search on 'File extension' or similar?
 
Use this folloing command line syntax of cut and paste in script.


#cd /source dir

# ls -la | awk '{print $9}' | grep JPG > file1

# for i in `cat file1`
do
name=`echo ${i} | awk -F. '{awk $1}'`
mv ${name}.JPG ${name}.jpg
done


Patel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top