Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-02-2007, 10:00 AM   #1
Registered: Sep 2006
Posts: 374

Rep: Reputation: 16
rename several files in bash or python


i would like to build a bash script or a python program that list a directory structure and, for all the files that it find, removes the extension java,v to java. How i do that?

Old 04-02-2007, 10:01 AM   #2
Registered: Sep 2006
Posts: 374

Original Poster
Rep: Reputation: 16
I think i found it.

for file in *.txt; do mv $file `echo $file | sed 's/\(.*\.\)txt/\1TXT/'`; done
Old 04-02-2007, 10:08 AM   #3
Registered: Sep 2006
Posts: 374

Original Poster
Rep: Reputation: 16
But, i've another question.

If i want to run this script inside each directory, how should i do it?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script? how to rename files in random way? lefty.crupps Linux - Software 16 11-03-2015 03:07 PM
Help with Bash Script - Rename Multiple Files embsupafly Programming 16 04-02-2010 04:50 AM
Bash script to traverse directory tree and rename files intramaweb Programming 3 10-08-2006 01:51 PM
Bash - Batch File Rename Help... emailarron Linux - Newbie 4 01-26-2006 08:35 AM
BASH USAGE: mass files rename sirpelidor Linux - General 8 09-20-2005 01:36 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration