This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.vbs
841 lines (597 loc) · 21.2 KB
/
convert.vbs
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
' ===========================================================================
' Marknotes conversion utilitiy
' https://github.com/cavo789/marknotes
'
' Author : Christophe Avonture
' Date : August 2017
'
' This script is for Windows OS. Make a copy of this script in a folder where you've
' .docx or .odt files and the script, thanks to pandoc (should be first installed), will
' convert these files into .md (markdown) ones.
'
' The .md files will then be used in the marknotes interface.
'
' The conversion will :
' * convert any .docx and .odt files present in the folder and his subfolders
' * create one .md file by .docx or .odt file
' * will extract every images present in .docx or .odt and will save them in a .images folder
' (there will be one subfolder in .images by processed file)
' * after the conversion, the original file will be moved in a .files folder
'
' Once the script has finished, you'll have :
' yourfolder
' \.files <-- the folder where the original file (.docx or .odt) have been moved
' \.images <-- the folder where embeded images (in documents) have been saved
' \*.md <-- one .md file by converted file
'
' The name of the folders (.files and .images) starts with a dot so these folders are "hidden"
' and therefore not displayed in the tree of marknotes (under Linux, a name starting with a
' dot means "hidden")
'
' ===========================================================================
' ### START OF CONFIGURATION #############################################
'
' Mention here the full path to the pandoc.exe on your system.
' If not yet installed, please install pandoc from http://pandoc.org/installing.html
Const cPandocExecutable = "C:\Users\adm.christophe.avont\AppData\Local\Pandoc\pandoc.exe"
' Enable or not the debug mode (is more verbose)
Const cDebug = True
'
' ### END OF CONFIGURATION ###############################################
' ---------------------------------------------------------------------------
' ---------------------------------------------------------------------------
' ---------------------------------------------------------------------------
' ---------------------------------------------------------------------------
' ---------------------------------------------------------------------------
' Except if you know what you're doing, don't change anything below this line
' ---------------------------------------------------------------------------
Dim cConvert, cFunctions, cFileSystem, cPandoc
' ---------------------------------------------------------------------------
'
' Define a class for the generic functions
'
' ---------------------------------------------------------------------------
Class clsFunctions
Private bDebugMode
Public Property Let DebugMode(bOnOff)
bDebugMode = bOnOff
End Property
Public Property Get DebugMode()
DebugMode = bDebugMode
End Property
' -------------------------------
'
' Little helper for echoing a message.
' Under Windows (double-clic on the script), a echo is a popup so by
' displaying a lot of information, this will be very annoying.
'
' echos will be always done
' * if bAlways is set on True
' * if the script was started with cscript i.e. console mode
' * if bOnlyDebug means that the echo will be done only if the debug mode is set
'
' -------------------------------
Sub Echo(sLine, bAlways, bOnlyDebug, wIndent)
If InStr(1, WScript.FullName, "wscript", vbTextCompare) Then
wIndent=0
sLine = Replace(sLine, "|", vbCrLf)
Else
sLine = Replace(sLine, "|", "")
End if
If (bAlways) Then
wScript.Echo Space(wIndent * 3) & sLine
Else
If InStr(1, WScript.FullName, "cscript", vbTextCompare) Then
' Started with cscript => do the echo on the console
If Not (bOnlyDebug) or ( (bOnlyDebug and DebugMode()) ) then
wScript.Echo Space(wIndent * 3) & sLine
End If
End If
End If
End Sub
' -------------------------------
'
' Sanitize a filename, remove special characters and keep only ASCII chars.
'
' -------------------------------
Function SanitizeFileName(sFileName)
Dim objRegExp
Dim sResult
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
' Strip non-ASCII characters
objRegExp.Pattern = "[^\u0000-\u007F]"
sResult = objRegExp.Replace(sFileName, "-")
' Replace some invalid characters
objRegExp.Pattern = "[(?*"",\\<>«&#~%{}\(\)\'+_û–.@:\/!;]+"
sResult = objRegExp.Replace(sResult, "-")
objRegExp.Pattern = "\-+"
sResult = objRegExp.Replace(sResult, "-")
' chr(150) is like a minus sign but bigger, used sometimes in Winword.
' That character will give problems so convert it as a minus one
sResult=replace(sResult, chr(150), "-")
SanitizeFileName = sResult
End Function
' -------------------------------
'
' in_array helper, check if a value is present in an array
'
' -------------------------------
Function in_array(value, arr)
Dim hay
in_array = False
value = trim(value)
For Each hay in arr
If trim(hay) = value Then
in_array = True
Exit For
End If
Next
End Function
' -------------------------------
'
' Remove specific tags from a string
' http://webdevel.blogspot.be/2005/05/strip-tags-vbscript.html
'
' For instance = to remove span, do something like :
'
' StripTags("<html>...<span id='JJ'>blabla</span>...", "span")
' -------------------------------
Private Function StripTags(sValue, sTag)
' set 'sTag' to empty string to strip all sTag
If sTag = "" Then sTag = "[a-zA-Z]+"
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
' tag to remove (based on http://regexplib.com/REDetails.aspx?regexp_id=211)
objRegExp.Pattern = "</?("+sTag+")(\s+\w+=(\w+|""[^""]*""|'[^']*'))*\s*?/?>"
StripTags = objRegExp.Replace(sValue, "")
End Function
' -------------------------------
'
' Conversion from .docx can generate a lot of <span> for, f.i., table
' of contents. Remove these span
'
' -------------------------------
Public Function RemoveHTMLTags(sValue)
sValue = StripTags(sValue, "span")
RemoveHTMLTags = sValue
End Function
' -------------------------------
'
' Remove non-ASCII characters from a string, replace them by an empty string
' https://stackoverflow.com/a/37025007/1065340
'
' -------------------------------
Public Function RemoveNonASCII(sValue)
Set objRegExp = New Regexp
objRegExp.Global = True
objRegExp.Pattern = "[^\u0000-\u007F]"
sValue = objRegExp.Replace(sValue, "")
Set objRegExp = Nothing
RemoveNonASCII = sValue
End Function
End Class
' ---------------------------------------------------------------------------
'
' Define a class for file's operations
'
' ---------------------------------------------------------------------------
Class clsFileSystem
Private bDebugMode
Private objFSO
Private colFiles
Public Property Let DebugMode(bOnOff)
bDebugMode = bOnOff
End Property
Public Property Get DebugMode()
DebugMode = bDebugMode
End Property
' -------------------------------
'
' Change the working, current, directory
'
' -------------------------------
Public Sub Chdir(sFolderName)
Set objShell = CreateObject("WScript.Shell")
objShell.CurrentDirectory = sFolderName
Set objShell = Nothing
End Sub
' -------------------------------
'
' Recursive function, called by RetrieveListOfFiles
' Scan every subfolders and retrieve the list of files that should be processed
'
' -------------------------------
Private Sub ShowSubFolders(Folder, arrSupportedFileExt)
Dim sParentName
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set objFiles = objFolder.Files
For Each f in objFiles
' Only process supported files
If (cFunctions.in_array(objFSO.GetExtensionName(f.Name), arrSupportedFileExt)) Then
' And only if there are not located in a folder called ".files"
sParentName = objFSO.GetParentFolderName(f.ParentFolder & "\" & f.Name)
sParentName = Mid(sParentName, InStrRev(sParentName, "\") + 1)
If (sParentName <> ".files") Then
colFiles.Add f.ParentFolder & "\" & f.Name
End If
End if
Next
Call ShowSubFolders(Subfolder, arrSupportedFileExt)
Set objFolder = Nothing
Set objFiles = Nothing
Next
End Sub
' -------------------------------
'
' Retrieve the list of files that should be processed
'
' -------------------------------
Public Function RetrieveListOfFiles(sFolder, arrSupportedFileExt)
' Initialize a collection that will contains the list of files that needs to be process
Set colFiles = CreateObject("System.Collections.ArrayList")
colFiles.Clear
For Each f In objFSO.GetFolder(sFolder).Files
If (cFunctions.in_array(objFSO.GetExtensionName(f.Name), arrSupportedFileExt)) Then
colFiles.Add f.ParentFolder & "\" & f.Name
End if
Next
' And make recursion
Call ShowSubfolders(objFSO.GetFolder(sFolder), arrSupportedFileExt)
' Sort the list
colFiles.Sort()
Set RetrieveListOfFiles = colFiles
End Function
' -------------------------------
'
' Archive the file
'
' -------------------------------
Sub MoveFile(sSourceName, sTargetName)
Call cFunctions.Echo ("Archive " & sSourceName, False, True, 2)
' If the .md file is still there, move the original file into the .files subfolder
If Not DebugMode() Then
If objFSO.FileExists(sTargetName) Then
objFSO.DeleteFile(sTargetName)
End if
Call objFSO.MoveFile(sSourceName, sTargetName)
Else
Call cFunctions.Echo("Don't archive when DebugMode is set", False, True, 3)
End if
End Sub
' -------------------------------
'
' Rename a file
'
' -------------------------------
Sub RenameFile(OldName, NewName)
Call objFSO.MoveFile(OldName, NewName)
End Sub
' -------------------------------
'
' Read the file's content. Be sure to open as a UTF-8 file
'
' -------------------------------
Function GetFileContent(sFileName)
Set objBinaryStream = CreateObject("ADODB.Stream")
objBinaryStream.CharSet = "utf-8"
objBinaryStream.Open
objBinaryStream.LoadFromFile sFileName
sContent = objBinaryStream.ReadText()
objBinaryStream.Close
Set objBinaryStream = Nothing
GetFileContent = sContent
End Function
' -------------------------------
'
' Create a file, UTF-8 encoded
'
' -------------------------------
Sub MakeUTF8(sFileName, sContent)
Dim objBinaryStream
' If the file already exists, delete it since we'll recreate it
If objFSO.FileExists(sFileName) Then
objFSO.DeleteFile(sFileName)
End If
Set objBinaryStream = CreateObject("ADODB.Stream")
objBinaryStream.CharSet = "utf-8"
objBinaryStream.Open
objBinaryStream.WriteText Replace(sContent, vbCrLF, vbLF), 0
objBinaryStream.SaveToFile sFileName, 2
objBinaryStream.Close
Set objBinaryStream = Nothing
End Sub
Private Sub Class_Initialize()
Set objFSO = CreateObject("Scripting.FileSystemObject")
End Sub
Private Sub Class_Terminate()
Set objFSO = Nothing
End Sub
End Class
Class clsPandoc
Private bDebugMode
Private sExecutable, sBaseName, sMediaFolder, sSourceExtension, sTargetFile
Private objFSO, objShell
Private sTmp
Public Property Let DebugMode(bOnOff)
bDebugMode = bOnOff
End Property
Public Property Get DebugMode()
DebugMode = bDebugMode
End Property
Public Property Let BaseName(sValue)
sBaseName = sValue
End Property
Public Property Get BaseName()
BaseName = sBaseName
End Property
Public Property Let MediaFolder(sValue)
sMediaFolder = sValue
End Property
Public Property Get MediaFolder()
MediaFolder = sMediaFolder
End Property
Public Property Let SourceExtension(sValue)
sSourceExtension = sValue
End Property
Public Property Get SourceExtension()
SourceExtension = sSourceExtension
End Property
Public Property Let TargetFile(sValue)
sTargetFile = sValue
End Property
Public Property Get TargetFile()
TargetFile = sTargetFile
End Property
' -------------------------------
'
' Set the path to the pandoc.exe file
'
' -------------------------------
Public Property Let Executable(sFileName)
If Not objFSO.FileExists(sFileName) Then
Call cFunctions.Echo("ERROR - Pandoc isn't installed on your system, " & _
"please install it from http://pandoc.org/installing.html.||" & _
"Once done, edit this .vbs script and adjust the cPandocExecutable " & _
"constant to where you've save pandoc", True, False, 1)
wScript.Quit
End If
sExecutable = sFileName
End Property
Public Property Get Executable()
Executable = sExecutable
End Property
' -------------------------------
'
' Build the pandoc command line with all required options
'
' -------------------------------
Private Function GetCommandLine()
' Build the pandoc command line
sTmp = Executable()
' -w (write-to) indicate the target desired format.
' Here, convert to a markdown_github format
sTmp = sTmp & " -w markdown_github"
' Convert accentuated characters in their HTML equivalent
' (f.i. & will be saved as &)
sTmp = sTmp & " --ascii"
' Set the heading style to #, ##, ### and not lines
'(see http://pandoc.org/MANUAL.html#atx-style-headers)
sTmp = sTmp & " --atx-headers"
' With none, pandoc will not wrap lines in the generated document.
sTmp = sTmp & " --wrap=none"
' The file is a stand-alone one (stand-alone)
sTmp = sTmp & " -s"
' Extract images and saved them in a .images/FILENAME subfolder
sTmp = sTmp & " --extract-media=.images/" & MediaFolder()
' Output filename
sTmp = sTmp & " -o """ & TargetFile() & """"
' And the source filename
sTmp = sTmp & " """ & BaseName() & "." & SourceExtension() & """"
'Call cFunctions.Echo (sTmp, False, True, 2)
GetCommandLine = sTmp
End Function
' -------------------------------
'
' Run pandoc, make the conversion
'
' -------------------------------
Public Sub Run
sPandoc = GetCommandLine()
' Don't show the window and, important, wait until the pandoc script is finished
Set objShell = CreateObject("WScript.Shell")
objShell.Run sPandoc, 0, 1
Set objShell = nothing
End Sub
Private Sub Class_Initialize()
Set objFSO = CreateObject("Scripting.FileSystemObject")
End Sub
Private Sub Class_Terminate()
Set objFSO = Nothing
End Sub
End Class
' ---------------------------------------------------------------------------
'
' Define the main class for the conversion
'
' ---------------------------------------------------------------------------
Class clsConvert
Private bDebugMode
Private sSourceFileName, sInitialDirectory
Private objFSO
Public Property Let DebugMode(bOnOff)
bDebugMode = bOnOff
End Property
Public Property Get DebugMode()
DebugMode = bDebugMode
End Property
Public Property Let InitialDirectory(sValue)
sInitialDirectory = sValue
End Property
Public Property Get InitialDirectory()
InitialDirectory = sInitialDirectory
End Property
Public Property Let SourceFileName(sValue)
sSourceFileName = sValue
End Property
Public Property Get SourceFileName()
SourceFileName = sSourceFileName
End Property
Public Property Get SourceFileRelativeName()
SourceFileRelativeName = Replace(sSourceFileName, sInitialDirectory, "")
End Property
Public Property Get SourceFileBaseName()
SourceFileBaseName = objFSO.GetBaseName(sSourceFileName)
End Property
Public Property Get SourceFileParentFolder()
SourceFileParentFolder = objFSO.GetParentFolderName(objFSO.GetFile(sSourceFileName)) & "\"
End Property
Public Property Get SourceFileExtensionName()
SourceFileExtensionName = objFSO.GetExtensionName(objFSO.GetFile(sSourceFileName))
End Property
Public Property Get TargetFileName()
TargetFileName = Replace(sSourceFileName, SourceFileExtensionName() , "md")
End Property
Public Property Get TargetMediaFolder()
TargetMediaFolder = Replace(SourceFileBaseName(), " ", "-")
End Property
' -------------------------------
'
' Display a small introduction
'
' -------------------------------
Sub ShowHeader
If InStr(1, WScript.FullName, "cscript", vbTextCompare) Then
Call cFunctions.Echo("==============================================================", False, False, 1)
Call cFunctions.Echo("= Marknotes Convert utility =", False, False, 1)
Call cFunctions.Echo("= Convert .docx and .odt files into .md ones =", False, False, 1)
Call cFunctions.Echo("= =", False, False, 1)
Call cFunctions.Echo("= Remark : only process the current folder, not recursively =", False, False, 1)
Call cFunctions.Echo("==============================================================", False, False, 1)
Call cFunctions.Echo("", False, False, 0)
Else
' Started in Windows by wecript.exe : the user has made a double-clic on the file.
wScript.Echo "Marknotes Convert utility is running... Please wait"
End If
End Sub
' -------------------------------
'
' Sanitize a filename, if needed, rename the file on the disk
'
' -------------------------------
Private Sub SanitizeFileName()
Dim sNewName
sNewName = cFunctions.SanitizeFileName(SourceFileBaseName)
If (sNewName <> SourceFileBaseName) Then
sNewName = SourceFileParentFolder & sNewName & "." & SourceFileExtensionName()
Call cFileSystem.RenameFile(SourceFileName, sNewName)
SourceFilename = sNewname
End If
End Sub
' -------------------------------
'
' Process a file
'
' -------------------------------
Sub Run()
Dim objFile
Dim sContent, sTemp
Set objFile = objFSO.GetFile(sSourceFileName)
' Be sure to have clean filenames
Call SanitizeFileName()
' Create subfolders for images and files
If Not (objFSO.FolderExists(SourceFileParentFolder() & ".images")) Then
objFSO.CreateFolder(SourceFileParentFolder() & ".images")
End If
If Not (objFSO.FolderExists(SourceFileParentFolder() & ".files")) Then
objFSO.CreateFolder(SourceFileParentFolder() & ".files")
End If
' Call pandoc and convert the file
cPandoc.BaseName = SourceFileBaseName()
cPandoc.SourceExtension = SourceFileExtensionName()
cPandoc.TargetFile = TargetFileName()
cPandoc.MediaFolder = TargetMediaFolder()
cPandoc.Run
' Now, read the generated .md file and replace a few things
If objFSO.FileExists(TargetFileName()) Then
' Read the file's content
sContent = cFileSystem.GetFileContent(TargetFileName())
' Add an intro : a link to the original file
sContent = "[Link to the original file, before conversion](%URL%.files/" & _
Replace(SourceFileBaseName()," ","%20") & "." & SourceFileExtensionName() & ")" & vbCrLf & vbCrLf & sContent
' ---------------------------------------------------------
'
' Add the %URL% variable so marknotes will keep absolute filename for images
sContent = Replace(sContent, "src=" & chr(34) & ".images/", "src=" & chr(34) & "%URL%.images/")
sContent = cFunctions.RemoveHTMLTags(sContent)
'sContent = cFunctions.RemoveNonASCII(sContent)
Call cFileSystem.MakeUTF8(TargetFileName(), sContent)
If objFSO.FileExists(TargetFileName()) Then
sTemp = SourceFileParentFolder() & ".files\" & SourceFileBaseName() & "." & SourceFileExtensionName()
Call cFileSystem.MoveFile(SourceFileName(), sTemp)
End if
If DebugMode() Then
'sContent = cFileSystem.GetFileContent(TargetFileName())
'Call cFunctions.Echo(sContent, False, True, 0)
End if
End if
End Sub
Private Sub Class_Initialize()
Set objFSO = CreateObject("Scripting.FileSystemObject")
End Sub
Private Sub Class_Terminate()
Set objFSO = Nothing
End Sub
End Class
' ###############
' # Entry point #
' ###############
Dim I
Set cFunctions = New clsFunctions
Set cFileSystem = New clsFileSystem
Set cPandoc = New clsPandoc
Set cConvert = New clsConvert
cFunctions.DebugMode = cDebug
cFileSystem.DebugMode = cDebug
cConvert.DebugMode = cDebug
cPandoc.DebugMode = cDebug
cPandoc.Executable = cPandocExecutable
Call cConvert.ShowHeader()
Set objFSO = CreateObject("Scripting.FileSystemObject")
sInitialDirectory = objFSO.GetAbsolutePathName(".") & "\"
cConvert.InitialDirectory = sInitialDirectory
' Retrieve the list of files that should be processed
Set colFiles = CreateObject("System.Collections.ArrayList")
Set colFiles = cFileSystem.RetrieveListOfFiles(sInitialDirectory, array("docx","odt"))
' Process them
Call cFunctions.Echo ("Number of files that will be processed : #" & colFiles.Count & _
vbCrLf, False, False, 1)
I = 1
For Each sFile In colFiles
Set objFile = objFSO.GetFile(sFile)
cConvert.SourceFileName = objFile.ParentFolder & "\" & objFile.Name
If (I > 1) Then Call cFunctions.Echo("", False, False, 0)
Call cFunctions.Echo("Process file " & I & "/" & colFiles.Count & " : " & _
cConvert.SourceFileRelativeName, False, False, 1)
If (objFile.ParentFolder <> sProcessingDir) Then
cFileSystem.Chdir(objFile.ParentFolder)
sProcessingDir = objFile.ParentFolder
End if
Call cConvert.Run
I = I + 1
Next
Call cFunctions.Echo("", False, False, 0)
' Restore the initial directory
cFileSystem.Chdir(sInitialDirectory)
Set objFSO = Nothing
Set colFiles = Nothing
Set cFunctions = Nothing
Set cFileSystem = Nothing
Set cPandoc = Nothing
Set cConvert = Nothing
If InStr(1, WScript.FullName, "wscript", vbTextCompare) Then
wScript.Echo "Marknotes Convert utility has finished."
End If