LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-25-2010, 09:59 AM   #1
seashell11
Member
 
Registered: Jul 2005
Distribution: Ubuntu Maverick
Posts: 81

Rep: Reputation: 15
Script to create index.html file


I need a script that can do this:
  • A script that searches all directories and subdirectories for .html files
  • When a .html file is found it creates a index.html file in that folder.
  • It then edits the index.html file and inserts links to all of the .html files that are in that folder into the body.
  • If no .html files are found, it searches for folders.
  • It then creates a index.html file with links to all of the folders.

What would be the best way to do this? Do you need more information?

Thank You
 
Old 09-25-2010, 10:05 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by seashell11 View Post
I need a script that can do this:
so basically you need someone to do all those stuff for you, right?

Quote:
What would be the best way to do this?
Start to learn a programming language if you have not. That's the best way. If you do not have one in mind, i recommend Python or shell scripting.
 
Old 09-25-2010, 10:08 AM   #3
seashell11
Member
 
Registered: Jul 2005
Distribution: Ubuntu Maverick
Posts: 81

Original Poster
Rep: Reputation: 15
I don't need anyone to do all of this for me. If someone would just point me in the right direction, I am quite capable of figuring stuff out on my own.
 
Old 09-25-2010, 10:17 AM   #4
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Since I know bash/shell and not Python, bash would be my personal choice.

In my script, I'd (this is very rough) use the `find` command to locate every directory within the parent tree, including the top directory. Then, inside every one of the found directories, I'd use `find` again (with a -maxdepth of 1) to locate all directories & html files present; then I'd create the index.html file, and insert (probably just using `echo`) a <href=link> or whatever, to each directory and/or html file present within my current directory.

Again, this is a pretty rough draft, but I think the idea is a decent one though pretty simplified in my description.

Once you begin to come up with some code and posting it for us to see where you're at, we can help you further with problem areas that you run into.

NOTE: You probably want to set up a testing directory tree, on which to test your script or program as it develops. I would actually have a testing tree, which I would copy to a second location on which to test my program; after each test run, I'd delete the copy of the testing tree and replace it fresh with a new copy, after having examined the results of the program run.

Good luck!
 
1 members found this post helpful.
Old 09-25-2010, 10:25 AM   #5
seashell11
Member
 
Registered: Jul 2005
Distribution: Ubuntu Maverick
Posts: 81

Original Poster
Rep: Reputation: 15
Thank you. This gives me a good start. If I need any more help, I will post back with the code that I have so far, and the results I am getting.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit index.html file of apache web server sanketpatel.86 Linux - Software 3 08-17-2010 12:34 AM
Script to create simple html from text file the_mulletator Programming 5 10-01-2009 04:23 PM
Apache problem - cannot get index.html file to show nebloof Linux - Software 3 01-15-2005 10:32 PM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM
Apache 2.0 search for index.html file pawlub Linux - Software 2 10-28-2003 10:03 AM


All times are GMT -5. The time now is 04:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration