Menu

[r11]: / chmfilejoiner.au3  Maximize  Restore  History

Download this file

64 lines (61 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$inputfile = FileOpenDialog("File Open", @MyDocumentsDir & "\", "ebook (*.pdf;*.html;*.htm;*.lit;*.pdb)", 0)
$inputdirectory = @WorkingDir
$inputfilename = StringReplace($inputfile, "|", @CRLF)
$inputfilename = StringReplace($inputfilename, $inputdirectory, "")
$inputfilename = StringTrimRight($inputfilename, 9)
;MsgBox(0, "", $inputdirectory)
$outputfile = FileOpenDialog("File Open", @MyDocumentsDir & "\", "HTML (*.html)", 1 + 8)
;FileOpen($outputfile, 1)
FileWriteLine($outputfile, "<body>")
; Check if file opened for reading OK
If $inputfile = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
; Read in 1 character at a time until the EOF is reached
$inputfilecounter = 1
$inputfilecounter2 = 1
$inputfilenumber = 1
ProgressOn("","Joining HTML", "", -1, -1, 1)
While 1
$positionstring = numberofzeros(StringLen($inputfilecounter2))
$inputfile = FileOpen($inputdirectory & $inputfilename & $positionstring& $inputfilecounter2 &".html", 0)
If $inputfile = -1 Then ExitLoop
$inputfilenumber = $inputfilenumber + 1
FileClose($inputfile)
$inputfilecounter2 = $inputfilecounter2 + 1
WEnd
$filenumpercent = 100 / $inputfilenumber
$line = "Joining HTML"
While 1
$positionstring = numberofzeros(StringLen($inputfilecounter))
;MsgBox(0, "",$inputdirectory & $inputfilename & $positionstring& $inputfilecounter &".html")
ProgressSet($filenumpercent, $inputfilename & $positionstring& $inputfilecounter &".html", $line)
$inputfile = FileOpen($inputdirectory & $inputfilename & $positionstring& $inputfilecounter &".html", 0)
If $inputfile = -1 Then ExitLoop
While 1
$line = FileReadLine($inputfile)
;$line = StringRegExpReplace($line, "", "")
If @error = -1 Then ExitLoop
$line = StringRegExpReplace($line, "(<body>)", "")
$line = StringRegExpReplace($line, "(</body>)", "")
FileWriteLine($outputfile, $line)
;MsgBox(0, "Char read:", $chars)
WEnd
FileClose($inputfile)
$inputfilecounter = $inputfilecounter + 1
$filenumpercent = $filenumpercent + $filenumpercent
WEnd
FileWriteLine($outputfile, "</body>")
FileClose($outputfile)
ProgressOff()
Func numberofzeros($digitlength)
$zerostring = ""
$digitlength = 4 - $digitlength
for $i = 1 to $digitlength Step 1
$zerostring = $zerostring &"0"
Next
Return ($zerostring)
EndFunc
;$inputfile = FileOpenDialog("File Open", @MyDocumentsDir & "\", "ebook (*.pdf;*.html;*.htm;*.lit;*.pdb)", 0)
;$outputfile = FileOpenDialog("File Open", @MyDocumentsDir & "\", "ebook (*.pdf;*.html;*.htm;*.lit;*.pdb)", 1 + 8)