#1 2009-10-12 10:35

ewsen
Member
Registered: 2009-10-12
Posts: 3

Rename the static site with a change links?

Can I use ReNamer for rename the static site with a change links? There is a directory site in which the statistical html files relink each other.
Need to assign each file name from <title> (that I know how to do). Also, after assigning a new name, make a detour of all html files and replace the old link to the new.
With something like this http://www.den4b.com/forum/viewtopic.php?id=167, only with the replacement text, which coincides with the old name for the new. And with over all html files.
It would be very helpful in the development of static websites.
--------
I have already started to do himself. I've done so far is

var
  Ext, FileNameOld1, FileNameNew1, 
  FileNameOld2, FileNameNew2: WideString;
  Contents: string;

begin
  FileNameOld1 := WideExtractFileName(FilePath);
  FileNameNew1 := WideExtractFileName(FileName);
  FileNameOld2 := WideExtractFileName(FilePath);
  FileNameNew2 := WideExtractFileName(FileName);
  Ext := WideExtractFileExt(FilePath);
  if not (WideSameText(Ext, '.txt') or WideSameText(Ext, '.htm') or WideSameText(Ext, '.html')) then Exit;
  Contents := FileReadContent(FilePath);
  Contents := WideReplaceText(Contents, '"'+FileNameOld1, '"'+FileNameNew1);
  Contents := WideReplaceText(Contents, '/'+FileNameOld2, '/'+FileNameNew2);
  FileWriteContent(FilePath, Contents); 
end.

This only works with the current file. 'll Show how to apply these operations

  Ext := WideExtractFileExt(FilePath);
  if not (WideSameText(Ext, '.txt') or WideSameText(Ext, '.htm') or WideSameText(Ext, '.html')) then Exit;
  Contents := FileReadContent(FilePath);
  Contents := WideReplaceText(Contents, '"'+FileNameOld1, '"'+FileNameNew1);
  Contents := WideReplaceText(Contents, '/'+FileNameOld2, '/'+FileNameNew2);
  FileWriteContent(FilePath, Contents); 

to all of Vail project or a directory with subdirectories.
Whatever after renaming the file, link to it changed in all files, including this file.

And how can you make this operation
Contents := WideReplaceText(Contents, '"'+FileNameOld1, '"'+FileNameNew1);
that after the quotes were allowed any number of spaces.
Can I insert something here
Contents := WideReplaceText(Contents, '"'+'any number of spaces???'+FileNameOld1, '"'+FileNameNew1);


Help please.

PS Если можно на русском

Last edited by ewsen (2009-10-13 09:52)

Offline

#2 2009-10-13 10:14

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Rename the static site with a change links?

It was a little bit difficult for me to understand what exactly you're trying to do, probably since English is not your first language. Can you give us clear examples of what the existing filenames on the site are, and what you want them to be? That will make things much simpler and then we can tell you the appropriate way to accomplish it.

P.S. If you prefer an answer in Russian (as Google Translate seems to suggest), then I guess someone else can help you out better.

Last edited by Andrew (2009-10-13 10:16)

Offline

#3 2009-10-13 10:56

ewsen
Member
Registered: 2009-10-12
Posts: 3

Re: Rename the static site with a change links?

I mean it.
There is a directory with the files static site.
site/index.html
site/page1.html
site/dir/page2.html

Content index.html

<html>
<title>Main page</title>
<body>
<a href="index.html">Main page</a>
<a href=" page1.html">Page one</a>
<a href="dir/page2.html">Page two</a>
</body>
</html>

Content page1.html

<html>
<title>Page one</title>
<body>
<a href="index.html">Main page</a>
<a href=" page1.html">Page one</a>
<a href="dir/page2.html">Page two</a>
</body>
</html>

Content page2.html

<html>
<title>Page two</title>
<body>
<a href="../index.html">Main page</a>
<a href="../page1.html">Page one</a>
<a href="page2.html">Page two</a>
</body>
</html>

After renaming the need to get those files
site/main-page.html
site/page-one.html
site/dir/page-two.html

With this content:
Content main-page.html

<html>
<title>Main page</title>
<body>
<a href="main-page.html">Main page</a>
<a href="page-one.html">Page one</a>
<a href="dir/page-two.html">Page two</a>
</body>
</html>

Content page-one.html

<html>
<title>Page one</title>
<body>
<a href="main-page.html">Main page</a>
<a href="page-one.html">Page one</a>
<a href="dir/page-two.html">Page two</a>
</body>
</html>

Content page-two.html

<html>
<title>Page two</title>
<body>
<a href="../main-page.html">Main page</a>
<a href="../page-one.html">Page one</a>
<a href="page-two.html">Page two</a>
</body>
</html>

How to rename the files, I know. How to do it with such modifications as files?

Last edited by ewsen (2009-10-13 11:02)

Offline

#4 2009-10-13 13:00

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Rename the static site with a change links?

Hi ewsen and welcome.

Thank you very much for your clear description what you want to do,

but sorry,
since ReNamer is for renaming the name of files
and not the content of them
you should better use the right tool for such an task.


----

You can use for example
TextCrawler form http://www.digitalvolcano.co.uk/content/textcrawler

Short HowTo:
- enter search for <a href="index.html">Main page</a>
- enter replace with <a href="main-page.html">Main page</a>
- click on the favorite star to save this

- enter next search
- enter next replace
- click on the favorite star to save this

- enter next search
- enter next replace
- click on the favorite star to save this

- and so on...

- then use "Tools > Batch Commands" and add all your search&replace-pairs to an job
- load an COPY off all your html files
- press [Find]
- if all went OK, press [Replace]

-------
There are a many such tools, like e.g.
BK ReplaceEm => http://www.snapfiles.com/get/bkreplace.html
Or
InfoRapid Search & Replace => http://www.snapfiles.com/reviews/InfoRa … rapid.html
or
MultiFInd => http://www.midlinesoft.com/multifind
or
Check out SnapFiles.com or NoNags.com or other repositories to find more of this.

HTH?  smile


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#5 2009-10-13 13:34

ewsen
Member
Registered: 2009-10-12
Posts: 3

Re: Rename the static site with a change links?

Hi Stefan
I know that there are many programs for searching and replacing. I use DreamWeawer for this. It can rename one file and links throughout the site will change. I also can batch replace text in all html files on your site with DreamWeawer.
But I need a program that can batch rename and replace the required text.
Acquainted with many programs, I found ReNamer 5.50. And he almost manages to correct my problem (code which in the first post replaces text only in a file that is currently renamed). I just need to ensure that this replacement was performed in all the files each time after assigning a new name.
Is ReNamer 5.50. not be able to do so with PascalScript?

PS When a static site is a lot of files will take a long time to compile a list of replacements. Will have to rename the files one by one, while compiling a list of replacements. This is a very long time smile

Last edited by ewsen (2009-10-13 13:39)

Offline

Board footer

Powered by FluxBB