 |
 |
How to rename all file in a site- and then fix links?
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
I'm converting a site from old-school HTML 3.2+ to be standards compliant, and need to rename all 100+ files in the site to have a new extension, as well as update the links in all of the files to reflect these changes. (I'd do it by hand, but the guy that has lots of linsk between specific pages.)
I found a program to do this called HTML Rename, but the Classic version doen't run on my Mac. Does anyone know of any other apps that do this, preferable Mac OS X native, but Classic or X11 is ok too?
Thanks in advance.
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by york28:
I'm converting a site from old-school HTML 3.2+ to be standards compliant, and need to rename all 100+ files in the site to have a new extension, as well as update the links in all of the files to reflect these changes. (I'd do it by hand, but the guy that has lots of linsk between specific pages.)
I found a program to do this called HTML Rename, but the Classic version doen't run on my Mac. Does anyone know of any other apps that do this, preferable Mac OS X native, but Classic or X11 is ok too?
Thanks in advance.
Your best and simplest best is the demo version of A Better Finder Rename, which you can find easily enough on Version Tracker. There's a number of similar tools, each which have varying degrees of power and user-friendliness, but ABFR just seems to work simply (I just used it then to blitz a folder of photoshop files I accidently saved with '.tiff.eps' back to '.eps'.
Doing a batch replace of your '.html' files to '.php' or '.shtml' or whatever should be pretty trivial with BBEdit, GoLive, Dreamweaver or your program of choice.
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
use the site window in Dreamweaver. every time you change a link, it will ask you if you want to update that link in any of the files which link to it.
back in the land of tsch, you could just run this to change filenames and drag a load of files onto it:
foreach filename (*)
mv "$filename.html" "$filename.php"
end
that seems to be broken in bash though. hmm.
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
If you are comfortable with the command line and shell scripting there are ways of doing this. The batch rename is simple... off the top of my head you could do something like this:
Code:
for fileName in `find . -iregex '.*\.htm'`; do mv $fileName `echo $fileName | sed "s/\.[hH][tT][mM]$/\.html/"`; done
Then a quick perl script to go through the pages and do the same thing... Sounds like fun to me...
Oh... note that there are single quotes, double quotes, and backquotes (US key above the tab key) in the line. All are necessary... Oh.. anyone know how to get teh version of sed on 10.3.2 to do case-insensitive, it didn't like the /I switch when I gave it...
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
Thanks for all the suggestions. I think that what I'm going to end up doing is renaming the files, and then just doing a search/replace sitewide for href="*", and replacing the value in quotes with a lowercase version, minus the "HTML" and plus "php". Make sense? I'll poat back with my results, looks like I'm going to be learning some Perl this week....
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by philzilla:
foreach filename (*)
mv "$filename.html" "$filename.php"
end
[tt]for fileName in `find . -iregex '.*\.htm'`; do mv $fileName `echo $fileName | sed "s/\.[hH][mM]$/\.html/"`; done
Ppppffffhhh... Geeks... 
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
Simon Mundy: Yes, yes I am... a professional geek in fact...
PS... I may have forgotten a $ at the end of the iregex... just to be safe...
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
Here's my solution for anyone that is interested:
I have been testing out the multiple file search/replace functions in TextWrangler, and low and behold, two of the presets do exactly what I needed, convert to lowercase all href and img src values. Replacing .html with .php globally was also a snap. Awesome!
I learned how to use the different search/replace expressions, and rather quickly rid myself of all font, b, i, and other tags. I tried to convert all tags to lowercase, but on some pages there were errors (like a missing >  that in turn caused the whole page to be converted. No problem, a quick run through HTML Tidy and all is well.
Thanks for the help everyone.
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|