rename multiple files recursively
Moderator: General Moderators
rename multiple files recursively
Hello. my issue is having hundreds of html files i need to rename with .php file extentions. .html to .php. my problem:
i have for instance, /news directory on my linux box. that dir has subdir's like jan, feb, mar..etc etc..and in those directories are more directories with numbers like 01, 02, etc etc. these directories have .html files that need to have their ext changed to php. how can i change all of these files to .php extentions. i would like to start at the base directory say the "march" directory and traverse each dir beneath it renaming all html files to .php.
is this possible?
thank you. i've searched for how to do this but have not found.
i have for instance, /news directory on my linux box. that dir has subdir's like jan, feb, mar..etc etc..and in those directories are more directories with numbers like 01, 02, etc etc. these directories have .html files that need to have their ext changed to php. how can i change all of these files to .php extentions. i would like to start at the base directory say the "march" directory and traverse each dir beneath it renaming all html files to .php.
is this possible?
thank you. i've searched for how to do this but have not found.
- Pyrite
- Forum Regular
- Posts: 769
- Joined: Tue Sep 23, 2003 11:07 pm
- Location: The Republic of Texas
- Contact:
It is possible of course, and I have a script somewhere to do it. I'll get back to you on it.
Btw: there's a Linux forum now for these kinds of questions.
Btw: there's a Linux forum now for these kinds of questions.
Last edited by Pyrite on Fri Dec 12, 2003 5:44 pm, edited 1 time in total.
- Pyrite
- Forum Regular
- Posts: 769
- Joined: Tue Sep 23, 2003 11:07 pm
- Location: The Republic of Texas
- Contact:
K, gotta get this nifty perl script.
http://www.blemished.net/chcase.html
Then you can do stuff like:
http://www.blemished.net/chcase.html
Then you can do stuff like:
Code: Select all
$ chcase -o -x 's/htm/php/' '*.php' RETI remember reading about a linux command that does this, I don't know where I put that printed documentation though. 
Check out:
http://linux.tucows.com/preview/8622.html
And:
Google: [google]rename multiple files recursively[/google]
Check out:
http://linux.tucows.com/preview/8622.html
And:
Google: [google]rename multiple files recursively[/google]
Last edited by m3mn0n on Fri Dec 12, 2003 6:28 pm, edited 1 time in total.
ok, here's a difficult one for you
i have successfully changed the extention of all of the html files to .php. Now i must insert a few lines of code in each of the php files at the very top. can a php script open all files ending in .php in a directory and insert some code at the very top of the page?
like at the top of all of my php files i need something like:
this is probably advanced but it's gonna be a headache to edit each file manually 
thanks very much!
like at the top of all of my php files i need something like:
Code: Select all
<?php
require('somefile.php');
//some conditional statements;
?>thanks very much!
i used
chcase:
i renamed chcase to rename.cgi and did this:
./rename.cgi -r -x 's/.html/.php/' '*.html'
that recursively changed .html in every .html file to .php.
worked like a charm. now i need something that will open all of the php files and place a strand of code at the top of each php page.
i renamed chcase to rename.cgi and did this:
./rename.cgi -r -x 's/.html/.php/' '*.html'
that recursively changed .html in every .html file to .php.
worked like a charm. now i need something that will open all of the php files and place a strand of code at the top of each php page.