Create Account

Username
Password
Remember me
Email
 
0

Any txt file to html converter??

10 comments, 173 views, posted 12:38 pm 22/06/2012 in Requests by mohit_117
mohit_117 has 7099 posts, 2261 threads, 911 points, location: India
Good Man di Lantern

Hi!

I've got about 1,400 txt files which I need to view in a browser through a page that's indexed them all...
And since these are just simple txt files, I thought it would be quite easy to convert them or view them in a browser... but now I'm having trouble finding a good non-installing utility that can batch convert it for me into html..

Please can someone provide a freeware or a dreamweaver tutorial to : BATCH CONVERT txt to html ???


Thanks..
-Mohit.

Comments

2
1:01 pm 22/06/2012

marksyzm

First create an empty html file in a folder, and in that same folder create another called textfiles/ and put all your text files in there. Make sure your empty html file uses jquery by adding the jquery script just above </body>

Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

Then run this script:

Code:

//1400 = number of text files by name - if they all have different file names then create an array with all of them named in it
var $body, header, footer;
$body = $('body');
header = '<html><head></head><body>';
footer = '</body></html>';
for (var i = 0; i < 1400
$body.queue(function(next){
$.ajax('textfile_'+i.toString()+'.txt',function(txt){
$body.append( '<h1>'textfile_'+i.toString()+'.txt</h1>' ).append(
$('<pre />').append(
$('<code />').html( header+txt.replace("\n","<br />")+footer )
)
);
next();
});
});

Should build you a giant list of all the files in one html document for you to copy and paste... LOL might take you a while to do it though. Really need to sort out that code tag

0
1:19 pm 22/06/2012

mohit_117

Quote by marksyzm:
all the files in one html document


Quote by marksyzm:
to copy and paste


Well, I needed separate html files for each txt file.... and don't intend to copy paste either... just plain linking via the index page to the html files folder... Could there be a C++ code to do this with the file-stream header file? I know about file handling in C++, but have forgotten it all!

1
2:04 pm 22/06/2012

mohit_117

found a software... and all txt files converted!!!

http://www.snapfiles.com/get/easytexttohtml.html

1
2:24 pm 22/06/2012

marksyzm

I wasn't that serious about my code - I was really looking for an HTML5 method of creating those files but browsers don't really allow you to do that yet - huge security risk. I could have made it so it prompts you to save on each file generated but that might have been a little painful. Thinking about it, maybe compression could have been accomplished so you get them all as a batch file however that seemed unrealistic at this stage

2
2:25 pm 22/06/2012

marksyzm

0
2:50 pm 22/06/2012

mohit_117

Well, it's done! That program had a template selection from a list of html files.. I edited one of the files, and started the batch... took me quite some time to understand the program and some html help from google, and it was done! The webpage is complete.... now will look for creating an app out of it tomorrow for android/windows phone/symbian and blackberry.... still have that link you pm'd me so will look into tutorials for that tomorrow!! Thanks mark!!

1
2:54 pm 22/06/2012

marksyzm

In context with that last link I sent you, a lot more people are using this now instead of phonegap as they're finding phonegap a bit tedious/crappy

http://www.appcelerator.com/

0
3:05 pm 22/06/2012

mohit_117

Will it convert html to apk without coding knowledge?? It doesn't say anywhere about that...

0
3:26 pm 22/06/2012

mohit_117

Seems Very useful....Will try it out...!!

Thanks again mark!

Add Comment

Log in via teoti, or register to add a comment!