Click to See Complete Forum and Search --> : Renaming multiple Files Extension


timbolt
09-10-2001, 12:08 PM
Hello!

I am converting a site written in basic html with SSI to PHP.

Have used:
perl -pi.bkp -e 's|<!--#include virtual="|include_once("|g' `find ./ -name \*.shtml`

and similar to successfully change the text of the files, but am having real difficulty in finding a suitable command line technique for going through the whole directory structure similarly and converting all the .shtml file names to .php!

Expect it be a derivative of:
find -name \*.shtml -exec ??????? '{}'

Thanks!
Tim

Taizong
09-10-2001, 12:39 PM
Use locate to grab all shtml, and then redirect to rename?

eXtremist
09-10-2001, 01:36 PM
Does it have to be a single command? It would be quite easy to write a perl script that's a few lines long to do this task..

timbolt
09-10-2001, 06:55 PM
Cheers!

I would try to use the 'power of the command-line'. Worked for the replacing, even though that also invoked perl.

Running a perl script to rename the files would be fine.

A bit of code would be appreciated!

Many thanks!
Tim

Pras
09-10-2001, 08:18 PM
Try this link: http://www.linux.com/howto/Bash-Prog-Intro-HOWTO-12.html#ss12.3

timbolt
09-11-2001, 09:05 AM
Thanks for the advice. looked at the script and got it to work, but not as well as intended.

On this system there is a "rename" command in my bash shell.

The usage:
rename .shtml .php *.shtml

works for files in that directory, but can I have this work recursively?

man rename

does not help much, except that the last argument is a list of files and hece I could do:
rename .shtml .php */*.shtml

and such, but was wondering if there is a more 'proper' way of doing it.

Thanks.