LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Changing extension of multiple files (https://www.linuxquestions.org/questions/programming-9/changing-extension-of-multiple-files-388053/)

DarthPooh 05-31-2006 09:43 PM

Quote:

Originally Posted by mikejac69
#!/bin/bash
#changing file extensions
for i in *.src
do
x=`echo "$i"|sed -e 's/.src/.c/'`
cp "$i" /home/mike/tester/"$x"
done

oops, missed the dots!!

I also see some others have already posted their scripts whilst I was writing mine :D

How can I make this script more generic? If i called the script 'ren', I would like 'ren' to be able to do all the following:

ren *.pl *.cgi
ren dan_* Daniel-*
ren *1980* *2006*
ren Jun.*.txt JUNE-*.doc

chenglim 06-01-2006 10:16 AM

in sch day.. we learn variable.
=)

$original = "src"
$change = "c"

s/$original/$change/

Hope it helps

DarthPooh 06-01-2006 10:59 AM

Quote:

Originally Posted by chenglim
in sch day.. we learn variable.
=)

$original = "src"
$change = "c"

s/$original/$change/

Hope it helps

:confused:


All times are GMT -5. The time now is 11:55 PM.