LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-30-2003, 11:50 PM   #1
bluewolf
LQ Newbie
 
Registered: Jan 2003
Location: Calgary Alberta Canada
Distribution: ?
Posts: 4

Rep: Reputation: 0
Writing shell script called "convert"


How do I write a shell script called "convert" that renames all files in the current dir with a .php3 extension to have a .php extension instead.
 
Old 01-31-2003, 12:10 AM   #2
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
This forum is for questions about the website itself, or suggestions. You probably want to ask this in the programming section, or Linux - General, but not here. Don't post another thread though, a mod or Jeremy will move this one for you to the correct forum.

In the future, please post threads in the correct forum.

Cool
 
Old 02-01-2003, 09:09 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Code:
#!/bin/bash

ls *.php4 | while read f ; do
        mv $f ${f%4}
done
Note that this does not check if the destination file allready exists!

You could also install the "mmv" (Multiple MoVe), if it's not allready installed on your system. "mmv" is made especially for this kind of thing, so you wouldn't need a script, but just one mmv command.
 
Old 02-04-2003, 10:52 PM   #4
bluewolf
LQ Newbie
 
Registered: Jan 2003
Location: Calgary Alberta Canada
Distribution: ?
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks HKO. Most appreciated, although I still don't understand it. I will get the hang of it yet.
 
  


Reply



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: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
Starting Java from shell script (Exception in thread "main") rolf_mueller Linux - Software 5 10-30-2004 02:11 AM
1. shell script "find and replace" on text 2. java GUI application randomx Programming 4 03-05-2004 01:01 PM
"batch script": writing and running Jalalabee Linux - Newbie 5 09-09-2003 11:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:22 PM.

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