Bottom of This Page |
(
Print Dir or Directory Printer / Print Dir eller Directory Printer
Description: Print a directory (folder)'s file names to a text file. / Beskrivelse: Udskriv et bibliotek's (mappe)'s filnavne til en tekst fil.
This program is being run under WSCRIPT. / Dette program køres under WSCRIPT.
Overview - Function(s)... / Oversigt - Funktion(er)...
- and Sub procedure(s)... / - og Sub procedure(r)...
A sub procedure is used exactly the same way as a function, the only difference being that it doesn't return a value and therefore can't be used as part of an argument. Sub procedures are used by Visual Basic to provide event handling. / En sub procedure anvendes på nøjagtig samme måde som en funktion, den eneste forskel er, at den ikke returnerer en værdi, og derfor ikke kan bruges som en del af et argument. Sub procedurer anvendes af Visual Basic til at tilvejebringe begivenhed håndtering.
Developed and tested under Microsoft Windows 7 Professional - Danish version. / Udviklet og testet under Microsoft Windows 7 Professional - dansk version.
' All variables must be declared before use.
Option Explicit
'
' printdir.vbs
' (- a VBScript which uses the root WSH (Windows Script Host) COM object "WScript")
'
' Author: Erik Oestergaard / Forfatter: Erik Oestergaard
' E-mail: http://www.erikoest.dk/contact.htm
' Homepage: http://www.erikoest.dk
'
' Licence: Free to use, but please share improvements.
' No warranty - use at own risk. / Licens: Fri brug, men del
' venligst forbedringer. Ingen garanti - brug paa eget ansvar.
'
' Print Dir or Directory Printer. / Print Dir eller Directory
' Printer.
'
' Print a directory (folder)'s file names to a text file. /
' Udskriv et bibliotek's (mappe)'s filnavne til en tekst fil.
'
' This program is being run under WSCRIPT. / Dette program koeres
' under WSCRIPT.
'
' Installation in English: Copy 'printdir.vbs' to an empty folder
' or directory. / Installation paa dansk: Kopier 'printdir.vbs'
' til en tom mappe eller bibliotek.
'
' Use in English: Run this 'printdir.vbs'
' script (double-click the script file name). / Brug paa dansk:
' Koer 'printdir.vbs' skriptet (dobbelt-klik paa
' skript filnavnet).
'
' Or: / Eller:
'
' Right-click the script file name and choose "Send to" -
' "Desktop (make shortcut)". Right-click the "PrintDir"
' desktop icon and choose "Properties". Then select the
' tap "Shortcut" and the input field "Destination" and
' add the parameters (all parameters must be specified in
' double quotes): /
' Hoejre-klik paa skript filnavnet og vaelg "Send til" -
' "Skrivebord (opret genvej)". Hoejre-klik paa "PrintDir"
' skrivebordsikonet og vaelg "Egenskaber". Vaelg saa
' fanen "Genvej" og indtastningsfeltet "Destination" og
' tilfoej parametrene (alle parametre skal angives i
' dobbelt citationstegn):
'
' (full path to)printdir.vbs "C:\test\myTest" "C:\test\mytest" "printdir.txt|printdir.htm|printdir.all" "Yes|No" "Yes|No" "Yes|No"
' /
' (fuld sti til)printdir.vbs "C:\test\myTest" "C:\test\mytest" "printdir.txt|printdir.htm|printdir.all" "Yes|No" "Yes|No" "Yes|No"
'
' where the parameters (in order) means... / hvor parametrene (i raekkefoelge) betyder...
'
' 1. parameter: Enter the full path for the input file(s) i.e. the full path to the input directory or folder /
' 1. parameter: Indtast den fulde sti for input fil(er), dvs. den fulde sti til input bibliotek eller mappe
'
' 2. parameter: Enter the full path for the output file(s) /
' 2. parameter: Indtast den fulde sti til output-fil(er)
'
' 3. parameter: Enter file name of the output text file
' Valid file extension(s):
' For a text file: ".txt" (default)
' For a HTML file: ".htm"
' - or use ".all" for selecting all of the valid file formats
' Warning:
' Output file(s) will be overwritten if it/they exists.
' /
' 3. parameter: Indtast filnavnet paa output tekstfil
' Gyldig filtypenavn(e):
' For en tekstfil: ".txt" (standard)
' For en HTML-fil: ".htm"
' - eller brug ".all" til at vaelge alle de gyldige filformater
' Advarsel:
' Output-fil(er) vil blive overskrevet, hvis den/de eksisterer.
'
' 4. parameter: Add link to "htm" or "html" file name(s) if output text file is a HTML file? (Default: No) - Valid values: Yes|No /
' 4. parameter: Tilfoej link til "htm" eller "html" filnavn(e), hvis output tekstfil er en HTML-fil? (Standard: Nej) - Gyldige vaerdier: Yes|No
'
' 5. parameter: Use sort criteria 'Sort Ascending [A-Z]' (Yes) or 'Sort Descending [Z-A]' (No)? (Default: Yes) - Valid values: Yes|No /
' 5. parameter: Brug sorteringskriterie 'Sorter stigende [A-Z]' (Ja) eller 'Sorter faldende [Z-A]' (Nej)? (Standard: Ja) - Gyldige vaerdier: Yes|No
'
' 6. parameter: Show site header and footer text? (Default: Yes) - Valid values: Yes|No /
' 6. parameter: Vis websted sidehoved og sidefod tekst? (Standard: Ja) - Gyldige vaerdier: Yes|No
'
' More information: / Mere information:
' http://www.erikoest.dk/scba_007.htm
'
' Version 1.0 / Version 1.0
'
' Latest release: March 5, 2016 / Seneste
' udgave: 5. marts 2016
'
' Define variables.
Dim strPathIn 'As String
Dim strPathOut 'As String
Dim strOutFileNameExt 'As String
Dim strOutFileExt 'As String
Dim bAddLinkToHtmFileName 'As Boolean
Dim bSortOrderAscending 'As Boolean
Dim bShowSiteHeaderAndFooterText 'As Boolean
' Initialize variables.
strPathIn = ""
strPathOut = ""
strOutFileNameExt = ""
strOutFileExt = ""
bAddLinkToHtmFileName = False ' Add link to htm file name(s) ('True' or 'False') [Default: False].
bSortOrderAscending = True ' Sort order selected by specifying the sort criteria 'Sort Ascending [A-Z]' (True) or 'Sort Descending [Z-A]' (False) [Default: True].
bShowSiteHeaderAndFooterText = True ' Show site header and footer text ('True' or 'False') [Default: True].
Main
Sub Main()
' Process Print Dir or Directory Printer.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs 'As Scripting.FileSystemObject
Dim fils 'As Scripting.Files
Dim fil 'As Scripting.File
Dim fol 'As Scripting.Folder
Dim ts 'As Scripting.TextStream
Dim strInputDirectory 'As String
Dim strInputFile 'As String
Dim strExtensions 'As String
Dim strExtension 'As String
Dim intCounter 'As Integer
Dim strMessageInfo 'As String
Dim f
Dim intFileAttributeValue 'As Integer
' Define variables.
'Dim EnglishMonthArr(1 To 12) As String
Dim EnglishMonthArr 'As String
' Option Base is used at module level to declare
' the default lower bound for array subscripts.
ReDim EnglishMonthArr(12) 'As String
Dim dtNow 'As Date ' Stores the current date and time from the client's system clock.
Dim tmpStr 'As String ' Temporary text.
Dim tmpFileNameStr 'As String
Dim intOutFileNumber 'As Integer
Dim IntValue 'As Long ' Iterator for loops.
Dim bDoSortListItems 'As Boolean
Dim sUseSortOrder 'As String
Dim bInSortMixLCaseAndUCaseLetters 'As Boolean
Dim StartLbound 'As Long
Dim EndUbound 'As Long
' Define and Initialize variables for a Dynamic Array - Start.
Dim IntDynamicArrayValue 'As Long
Dim sFound 'As String
Dim CurUbound 'As Long
Dim StartUbound 'As Long
StartUbound = 50
'Dim TextLineDynamicArrayList(StartUbound) As String
Dim TextLineDynamicArrayList 'As Variant
' Option Base is used at module level to declare
' the default lower bound for array subscripts.
ReDim TextLineDynamicArrayList(StartUbound)
CurUbound = StartUbound
IntDynamicArrayValue = -1
sFound = "" ' Found text.
' Define and Initialize variables for a Dynamic Array - End.
' Initialize variables.
EnglishMonthArr(1) = "January"
EnglishMonthArr(2) = "February"
EnglishMonthArr(3) = "March"
EnglishMonthArr(4) = "April"
EnglishMonthArr(5) = "May"
EnglishMonthArr(6) = "June"
EnglishMonthArr(7) = "July"
EnglishMonthArr(8) = "August"
EnglishMonthArr(9) = "September"
EnglishMonthArr(10) = "October"
EnglishMonthArr(11) = "November"
EnglishMonthArr(12) = "December"
'MsgBox ("EnglishMonthArr(#): " & "StartLbound = " & CStr(LBound(EnglishMonthArr)) & " ; " & "EndUbound = " & CStr(UBound(EnglishMonthArr))) ' Only for the purpose of debugging.
'MsgBox ("EnglishMonthArr(0) = """ & CStr(EnglishMonthArr(0)) & """ - EnglishMonthArr(12) = """ & CStr(EnglishMonthArr(12)) & """") ' Only for the purpose of debugging.
dtNow = Now ' Stores the current date and time from the client's system clock.
tmpStr = "" ' Temporary text.
tmpFileNameStr = ""
' Note: 'True' [Mode: Do sort the list items] or 'False' [Mode: Do not sort the list items].
' Bemaerk: 'True' (Sand) [Maade: Sorter list elementerne] eller 'False' (Falsk) [Maade: Sorter ikke list elementerne].
bDoSortListItems = True ' See remark above. / Se bemaerkning ovenfor.
' Note: Sort order selected by specifying the sort criteria 'Sort Ascending [A-Z]' (Ascending) or
' 'Sort Descending [Z-A]' (Descending) [Default: Ascending].
' Bemaerk: Sorteringsraekkefoelge valgt ved at bestemme sorteringskriteriet 'Sorter stigende [A-Z]' (Stigende) eller
' 'Sorter faldende [Z-A]' (Faldende) [Standard: Stigende].
sUseSortOrder = "Ascending" ' See remark above. / Se bemaerkning ovenfor.
' Note: 'True' [Mode: In sort do mix lowercase and uppercase letters] or 'False' [Mode: In sort do not mix lowercase and uppercase letters].
' Bemaerk: 'True' (Sand) [Maade: I sortering bland smaa og store bogstaver] eller 'False' (Falsk) [Maade: I sortering bland ikke smaa og store bogstaver].
bInSortMixLCaseAndUCaseLetters = True ' See remark above. / Se bemaerkning ovenfor.
If Not (GetArguments()) Then
' Now check to see if the proper values have been supplied in one way or the other - otherwise...
'MsgBox "Fatal Error: The proper values for this program have *not* been supplied in one way or the other. The program finishes.", vbOKOnly, "Print Dir or Directory Printer"
' All done. Return the errorlevel. false (errorlevel 1) | true (errorlevel 0)
WScript.Quit 1
End If
'MsgBox ("strPathIn = """ & strPathIn & """ " & "strPathOut = """ & strPathOut & """ " & "strOutFileNameExt = """ & strOutFileNameExt & """") ' Only for the purpose of debugging.
If Lcase(Right(Wscript.FullName, 11)) = "wscript.exe" Then
'If MsgBox ("This program is being run under WSCRIPT. Always work on a copy of the original file(s)! Results will be stored in a log at " & Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "log" & ". Continue?", vbOkCancel, "Print Dir or Directory Printer") = vbCancel Then Wscript.Quit
If MsgBox ("This program is being run under WSCRIPT. Always work on a copy of the original file(s)!" & " Continue?", vbOkCancel, "Print Dir or Directory Printer") = vbCancel Then Wscript.Quit
Else
MsgBox "This program is being run under CSCRIPT. Run this program under WSCRIPT.", vbOKOnly, "Print Dir or Directory Printer"
'Wscript.Quit
Exit Sub
End If
' Force "wscript".
Force("wscript")
' Note: Sort order selected by specifying the sort criteria 'Sort Ascending [A-Z]' (Ascending) or
' 'Sort Descending [Z-A]' (Descending) [Default: Ascending].
' Bemaerk: Sorteringsraekkefoelge valgt ved at bestemme sorteringskriteriet 'Sorter stigende [A-Z]' (Stigende) eller
' 'Sorter faldende [Z-A]' (Faldende) [Standard: Stigende].
If bSortOrderAscending = True Then
' Use sort criteria 'Sort Ascending [A-Z]' (True). [Default]
sUseSortOrder = "Ascending" ' See remark above. / Se bemaerkning ovenfor.
Else
' Use sort criteria 'Sort Descending [Z-A]' (False).
sUseSortOrder = "Descending" ' See remark above. / Se bemaerkning ovenfor.
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set fol = fs.GetFolder(strPathIn)
Set fils = fol.Files
intCounter = 0
strMessageInfo = ""
For Each fil In fils
intCounter = intCounter + 1
'MsgBox ("fil.Name = " & fil.Name) ' Only for the purpose of debugging.
'strInputFile = strInputDirectory & "\" & fil.Name ' Full path and file name.
'MsgBox ("strInputFile = " & strInputFile) ' Only for the purpose of debugging.
' Make sure we will be working with the long file name.
'strInputFile = LongName(strInputFile)
'MsgBox ("strInputFile = " & strInputFile) ' Only for the purpose of debugging.
' Make an Array line out of each file name.
IntDynamicArrayValue = IntDynamicArrayValue + 1 ' Update the counter variable.
tmpStr = fil.Name
TextLineDynamicArrayList(IntDynamicArrayValue) = tmpStr
If IntDynamicArrayValue = CurUbound Then
CurUbound = CurUbound + StartUbound
'ReDim Preserve TextLineDynamicArrayList(CurUbound) As String
ReDim Preserve TextLineDynamicArrayList(CurUbound)
End If
Next
' Clean up.
Set fils = Nothing
Set fol = Nothing
Set fs = Nothing
If IntDynamicArrayValue <> -1 Then
'ReDim Preserve TextLineDynamicArrayList(IntDynamicArrayValue) As String
ReDim Preserve TextLineDynamicArrayList(IntDynamicArrayValue)
Else
'ReDim TextLineDynamicArrayList() As String
ReDim TextLineDynamicArrayList(0)
End If
If IntDynamicArrayValue = -1 Then
' Found no selected file(s).
' Note: TextLineDynamicArrayList: Must contain at least one found file.
'MsgBox "In " & Chr(34) & strPathIn & "*" & Chr(34) & " no matching file(s) were found" & ".", _
'Title:="Info", buttons:=vbInformation + vbOKOnly
MsgBox "In " & Chr(34) & strPathIn & "*" & Chr(34) & " no matching file(s) were found.", vbOKOnly, "Print Dir or Directory Printer"
'GoTo Exit_doPrintDir
Exit Sub
End If
' Note: 'True' [Mode: In sort do mix lowercase and uppercase letters] or 'False' [Mode: In sort do not mix lowercase and uppercase letters].
' Bemaerk: 'True' (Sand) [Maade: I sortering bland smaa og store bogstaver] eller 'False' (Falsk) [Maade: I sortering bland ikke smaa og store bogstaver].
If bInSortMixLCaseAndUCaseLetters = False Then ' See remark above. / Se bemaerkning ovenfor.
' Use Standard Sort Algorithm.
'TextLineDynamicArrayList() = doBubbleSortMyList(TextLineDynamicArrayList(), bDoSortListItems, sUseSortOrder, True) ' Bubble Sort My List.
Call doBubbleSortMyList(TextLineDynamicArrayList, bDoSortListItems, sUseSortOrder, True) ' Bubble Sort My List.
Else
' First:
' Use Standard Sort Algorithm.
'TextLineDynamicArrayList() = doBubbleSortMyList(TextLineDynamicArrayList(), bDoSortListItems, sUseSortOrder, True) ' Bubble Sort My List.
Call doBubbleSortMyList(TextLineDynamicArrayList, bDoSortListItems, sUseSortOrder, True) ' Bubble Sort My List.
' Second:
' Use Customized Sort Algorithm.
'TextLineDynamicArrayList() = doBubbleSortMyList(TextLineDynamicArrayList(), bDoSortListItems, sUseSortOrder, False) ' Bubble Sort My List.
Call doBubbleSortMyList(TextLineDynamicArrayList, bDoSortListItems, sUseSortOrder, False) ' Bubble Sort My List.
End If
' Note: TextLineDynamicArrayList: Must contain at least one found file.
' Sorted List.
' Initialize variables.
StartLbound = LBound(TextLineDynamicArrayList)
EndUbound = UBound(TextLineDynamicArrayList)
' ***** ----- Text output file start ----- *****
If Lcase(strOutFileExt) = Lcase(Trim("txt")) Or Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is 'txt' or 'all'.
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt"), ForWriting, True)
If bShowSiteHeaderAndFooterText = True Then
' Do show site header and footer text. [Default]
ts.Write "Print Dir or Directory Printer" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
tmpStr = "Generated by Print Dir or Directory Printer "
ts.Write tmpStr & vbCrLf
tmpStr = "[ http://www.erikoest.dk/download.htm ] VBS - a VBScript "
ts.Write tmpStr & vbCrLf
tmpStr = "which uses the root WSH (Windows Script Host) "
ts.Write tmpStr & vbCrLf
tmpStr = "COM object " & Chr(34) & "WScript" & Chr(34) & " (Version 1.0) on... "
ts.Write tmpStr & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
tmpStr = doFormatNum(CInt(Month(dtNow)), 2) & "/" & doFormatNum(CInt(Day(dtNow)), 2) & _
"/" & CStr(Year(dtNow)) & " at " & doFormatNum(CInt(Hour(dtNow)), 2) & ":" & _
doFormatNum(CInt(Minute(dtNow)), 2) & ":" & doFormatNum(CInt(Second(dtNow)), 2) & _
" (formatted as: MM/DD/YYYY HH:MM:SS)."
'ts.Write tmpStr & vbCrLf
ts.Write CStr(dtNow) & "." & vbCrLf
ts.Write "Input file: " & Chr(34) & strPathIn & "*" & Chr(34) & "." & vbCrLf
ts.Write "Output file: " & Chr(34) & (strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt") & Chr(34) & "." & vbCrLf
If (EndUbound + 1) = 1 Then ' Correct for zero-based index.
tmpStr = "Found " & CStr(EndUbound + 1) & " file." ' Correct for zero-based index.
Else
tmpStr = "Found " & CStr(EndUbound + 1) & " files." ' Correct for zero-based index.
End If
ts.Write tmpStr & vbCrLf
tmpStr = "::" & " " & String(16, "*") & " " & "Running " & _
"Print Dir" & " " & String(16, "*") ' Fill with "*".
ts.Write tmpStr & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
Else
' Do not show site header and footer text.
ts.Write "" & vbCrLf ' Print blank line to file.
End If
' ***** Repeated output line(s) or paragraph(s) start *****
' *
For IntValue = StartLbound To EndUbound Step 1
' Write the sorted Array line(s) back to line(s) in the text file.
tmpFileNameStr = CStr(TextLineDynamicArrayList(IntValue))
ts.Write tmpFileNameStr & vbCrLf
Next 'IntValue
' *
' ***** Repeated output line(s) or paragraph(s) end *****
If bShowSiteHeaderAndFooterText = True Then
' Do show site header and footer text. [Default]
ts.Write "" & vbCrLf ' Print blank line to file.
tmpStr = "::" & " " & String(16, "*") & String(Len(" "), "*") & String(Len("Running "), "*") & _
String(Len("Print Dir"), "*") & String(Len(" "), "*") & String(16, "*") ' Fill with "*".
ts.Write tmpStr & vbCrLf
tmpStr = "Copyright (c) " & "1997 - " & CStr(Year(dtNow)) & " Print Dir or Directory Printer."
ts.Write tmpStr & vbCrLf
Else
' Do not show site header and footer text.
'ts.Write "" & vbCrLf ' Print blank line to file.
End If
ts.Write "" & vbCrLf ' Print blank line to file.
'ts.Write ""
ts.Close
' Clean up.
Set ts = Nothing
Set fs = Nothing
End If
' ***** ----- Text output file end ----- *****
' ***** ----- HTML output file start ----- *****
If Lcase(strOutFileExt) = Lcase(Trim("htm")) Or Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is 'htm' or 'all'.
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm"), ForWriting, True)
ts.Write "<!DOCTYPE HTML PUBLIC " & Chr(34) & "-//W3C//DTD HTML 3.2//EN" & Chr(34) & ">" & vbCrLf
ts.Write "<html>" & vbCrLf
ts.Write "<head>" & vbCrLf
ts.Write "<title>Print Dir or Directory Printer</title>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Publication_Date" & Chr(34) & " content=" & Chr(34) & "March 29, 1997" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta name=" & Chr(34) & "GENERATOR" & Chr(34) & " content=" & Chr(34) & "Print Dir or Directory Printer" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Expires" & Chr(34) & " content=" & Chr(34) & "Tuesday, 01-Jan-1980 12:00:00 GMT" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Content-Language" & Chr(34) & " content=" & Chr(34) & "en" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<!-- ISO Latin-1 character set (label: iso-8859-1) are defined by the ISO Standard ISO8859-1 for use with Western European languages. -->" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Content-Type" & Chr(34) & " content=" & Chr(34) & "text/html; charset=iso-8859-1" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Cache-Control" & Chr(34) & " content=" & Chr(34) & "no-cache" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Cache-Control" & Chr(34) & " content=" & Chr(34) & "no-store" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Pragma" & Chr(34) & " content=" & Chr(34) & "no-cache" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Keywords" & Chr(34) & " content=" & Chr(34) & "print, dir, or, directory, printer, folder, udskriv, mappe, eller, mappe, printer, bibliotek" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Owner" & Chr(34) & " content=" & Chr(34) & "Print Dir or Directory Printer" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta http-equiv=" & Chr(34) & "Reply to" & Chr(34) & " content=" & Chr(34) & "Info: http://www.erikoest.dk/contact.htm" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta name=" & Chr(34) & "Page-ID" & Chr(34) & " content=" & Chr(34) & "Print Dir or Directory Printer" & Chr(34) & "></meta>" & vbCrLf
ts.Write "<meta name=" & Chr(34) & "Description" & Chr(34) & " content=" & Chr(34) & "Print Dir or Directory Printer / Udskriv mappe eller Mappe printer" & Chr(34) & "></meta>" & vbCrLf
tmpStr = "<meta name=" & Chr(34) & "Document-ID" & Chr(34) & " content=" & _
Chr(34) & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm" & Chr(34) & "></meta>"
ts.Write tmpStr & vbCrLf
tmpStr = "<meta name=" & Chr(34) & "Last-modified" & Chr(34) & " content=" & _
Chr(34) & EnglishMonthArr(CInt(Month(dtNow))) & " " & CStr(Day(dtNow)) & ", " _
& CStr(Year(dtNow)) & Chr(34) & "></meta>"
ts.Write tmpStr & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<meta name=" & Chr(34) & "Robots" & Chr(34) & " content=" & Chr(34) & "noindex,nofollow" & Chr(34) & "></meta>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<style>" & vbCrLf
ts.Write "<!--" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "body {" & vbCrLf
ts.Write String(2, " ") & "color: #000000;" & String(30, " ") & "/* (black) */" & vbCrLf
ts.Write String(2, " ") & "background-color: #FFFFFF;" & String(19, " ") & "/* (white) */" & vbCrLf
ts.Write String(2, " ") & "background-image: none;" & vbCrLf
ts.Write String(2, " ") & "background-repeat: repeat;" & vbCrLf
ts.Write "}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "A:link { color: #FF0000 }" & String(7, " ") & "/* LINK (not visited) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "A:visited { color: #800080 }" & String(4, " ") & "/* VLINK (visited) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "A:active { color: #8B0000 }" & String(5, " ") & "/* ALINK (active - just clicked) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.copyrighttext {" & vbCrLf
ts.Write String(2, " ") & "font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & "," & vbCrLf
ts.Write String(6, " ") & "serif, sans-serif, cursive, fantasy, monospace;" & vbCrLf
ts.Write String(2, " ") & "font-weight: normal;" & vbCrLf
ts.Write String(2, " ") & "font-size: 8pt;" & vbCrLf
ts.Write String(2, " ") & "font-style: italic;" & vbCrLf
ts.Write String(2, " ") & "color: #000000;" & String(30, " ") & "/* (black) */" & vbCrLf
ts.Write "}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.headingtext {" & vbCrLf
ts.Write String(2, " ") & "font-weight: bold;" & vbCrLf
ts.Write "}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.redtext { color: #FF0000 }" & String(16, " ") & "/* (red) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.greentext { color: #008000 }" & String(14, " ") & "/* (green) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.bluetext { color: #0000FF }" & String(15, " ") & "/* (blue) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.notetext {" & vbCrLf
ts.Write String(2, " ") & "font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & "," & vbCrLf
ts.Write String(6, " ") & "serif, sans-serif, cursive, fantasy, monospace;" & vbCrLf
ts.Write String(2, " ") & "font-weight: normal;" & vbCrLf
ts.Write String(2, " ") & "font-size: 8pt;" & vbCrLf
ts.Write String(2, " ") & "font-style: normal;" & vbCrLf
ts.Write String(2, " ") & "color: #000000;" & String(30, " ") & "/* (black) */" & vbCrLf
ts.Write "}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.premisetext { color: #000000; font-weight: normal; font-style: italic }" & String(13, " ") & "/* (black) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "span.premisetext2 { color: #9D9DA1; font-weight: normal; font-style: italic }" & String(12, " ") & "/* ([user-defined] dark grey) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write ".very-minor-text {font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & ", serif, sans-serif, cursive, fantasy, monospace; font-size: 60%; font-weight: normal; cursor: default}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write ".minor-text {font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & ", serif, sans-serif, cursive, fantasy, monospace; font-size: 80%; font-weight: normal; cursor: default}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write ".major-text {font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & ", serif, sans-serif, cursive, fantasy, monospace; font-size: 100%; font-weight: normal; cursor: default}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write ".very-major-text {font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & ", serif, sans-serif, cursive, fantasy, monospace; font-size: 120%; font-weight: bold; cursor: default}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "h1, h2, h3, h4, h5, h6 {" & vbCrLf
ts.Write String(2, " ") & "font-family: Arial, Helvetica, " & Chr(34) & "Times New Roman" & Chr(34) & "," & vbCrLf
ts.Write String(6, " ") & "serif, sans-serif, cursive, fantasy, monospace;" & vbCrLf
ts.Write String(2, " ") & "font-weight: 500;" & vbCrLf
ts.Write String(2, " ") & "text-decoration: none;" & vbCrLf
ts.Write "}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "h1, h2, h3, h4, h5, h6 { color: green }" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "code { color: blue }" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "li {" & vbCrLf
ts.Write String(2, " ") & "list-style-image: none;" & String(22, " ") & "/* Specifies URL for image to use as list item marker; replaced marker specified by 'list-style-type' */" & vbCrLf
ts.Write String(2, " ") & "list-style-position: outside;" & String(16, " ") & "/* Positioning of marker with respect to list content */" & vbCrLf
ts.Write String(2, " ") & "color: #000000;" & String(30, " ") & "/* (black) */" & vbCrLf
ts.Write String(2, " ") & "text-decoration: none;" & vbCrLf
ts.Write String(2, " ") & "cursor: default;" & vbCrLf
ts.Write "}" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "img { border-color: #000000 }" & String(18, " ") & "/* (black) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "p { color: #000000 }" & String(27, " ") & "/* (black) */" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "-->" & vbCrLf
ts.Write "</style>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<script language=" & Chr(34) & "JavaScript" & Chr(34) & ">" & vbCrLf
ts.Write "<!-- Beginning of JavaScript Applet and hide from old browsers -----" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "// - End of JavaScript code and done hiding -->" & vbCrLf
ts.Write "</script>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "</head>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<body bgcolor=" & Chr(34) & "#FFFFFF" & Chr(34) & " text=" & Chr(34) & "#000000" & Chr(34) & " link=" & Chr(34) & "#FF0000" & Chr(34) & " alink=" & Chr(34) & "#8B0000" & Chr(34) & " vlink=" & Chr(34) & "#800080" & Chr(34) & ">" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
If bShowSiteHeaderAndFooterText = True Then
' Do show site header and footer text. [Default]
ts.Write "<h2 align=" & Chr(34) & "center" & Chr(34) & ">Print Dir <i>or</i> Directory Printer</h2>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
tmpStr = "<p align=" & Chr(34) & "left" & Chr(34) & "><span class=" & Chr(34) & _
"greentext" & Chr(34) & "><small>Generated by <a href=" & Chr(34) & _
"http://www.erikoest.dk/download.htm" & Chr(34) & " target=" & Chr(34) & "_blank" & _
Chr(34) & ">Print Dir</a> <i>or</i> <a href=" & Chr(34) & _
"http://www.erikoest.dk/download.htm" & Chr(34) & " target=" & Chr(34) & "_blank" & _
Chr(34) & ">Directory Printer</a> VBS <nobr>- a</nobr> <b>V</b><b>B</b><b>S</b>cript " & _
"which uses the root WSH (<b>W</b>indows <b>S</b>cript <b>H</b>ost) " & _
"COM object "<b>W</b><b>S</b>cript" (Version 1.0) <nobr>on...</nobr> </small></span></p>"
ts.Write tmpStr & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
tmpStr = "<p align=" & Chr(34) & "left" & Chr(34) & ">" & _
doFormatNum(CInt(Month(dtNow)), 2) & "/" & doFormatNum(CInt(Day(dtNow)), 2) & _
"/" & CStr(Year(dtNow)) & " at " & doFormatNum(CInt(Hour(dtNow)), 2) & ":" & _
doFormatNum(CInt(Minute(dtNow)), 2) & ":" & doFormatNum(CInt(Second(dtNow)), 2) & _
" (formatted as: MM/DD/YYYY HH:MM:SS).</p>"
'ts.Write tmpStr & vbCrLf
'ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & ">" & CStr(dtNow) & ".</p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & ">Input file: "<code>" & strPathIn & "*" & "</code>".</p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & ">Output file: "<code>" & (strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm") & "</code>".</p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
If (EndUbound + 1) = 1 Then ' Correct for zero-based index.
tmpStr = "Found " & CStr(EndUbound + 1) & " file." ' Correct for zero-based index.
Else
tmpStr = "Found " & CStr(EndUbound + 1) & " files." ' Correct for zero-based index.
End If
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & ">" & tmpStr & "</p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<hr>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "> </p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
Else
' Do not show site header and footer text.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "> </p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
End If
' ***** Repeated output line(s) or paragraph(s) start *****
' *
For IntValue = StartLbound To EndUbound Step 1
' Write the sorted Array line(s) back to line(s) in the text file.
tmpFileNameStr = CStr(TextLineDynamicArrayList(IntValue))
If bAddLinkToHtmFileName = False Then
' Do not add link to htm file name(s). [Default]
ts.Write "<p align=""left"">" & tmpFileNameStr & "</p>" & vbCrLf
Else
' Do add link to htm file name(s).
If ( InStrRev(tmpFileNameStr, ".") <> 0 And Lcase(Mid(tmpFileNameStr, InStrRev(tmpFileNameStr, ".") + 1)) = Lcase(Trim("htm")) ) _
Or ( InStrRev(tmpFileNameStr, ".") <> 0 And Lcase(Mid(tmpFileNameStr, InStrRev(tmpFileNameStr, ".") + 1)) = Lcase(Trim("html")) ) Then
' File extension found And This is a 'htm' file name.
ts.Write "<p align=""left"">" & "<a href=""" & tmpFileNameStr & """>" & tmpFileNameStr & "</a>" & "</p>" & vbCrLf
Else
' File extension not found Or This is not a 'htm' or 'html' file name.
ts.Write "<p align=""left"">" & tmpFileNameStr & "</p>" & vbCrLf
End If
End If
ts.Write "" & vbCrLf ' Print blank line to file.
Next 'IntValue
' *
' ***** Repeated output line(s) or paragraph(s) end *****
If bShowSiteHeaderAndFooterText = True Then
' Do show site header and footer text. [Default]
'ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "> </p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<hr>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "><a href=" & Chr(34) & "javascript:history.go(-1)" & Chr(34) & " onmouseover=" & Chr(34) & "window.status=' Return ' ;return true" & Chr(34) & " onmouseout=" & Chr(34) & "window.status=' ' ;return true" & Chr(34) & ">Return</a></p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "> </p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "><i><small><span class=" & Chr(34) & "copyrighttext" & Chr(34) & ">" & vbCrLf
tmpStr = "©1997 - " & CStr(Year(dtNow)) & " Print Dir <i>or</i> Directory Printer."
ts.Write tmpStr & vbCrLf
ts.Write "</span></small></i></p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
Else
' Do not show site header and footer text.
ts.Write "<p align=" & Chr(34) & "left" & Chr(34) & "> </p>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
End If
ts.Write "</body>" & vbCrLf
ts.Write "</html>" & vbCrLf
ts.Write "" & vbCrLf ' Print blank line to file.
'ts.Write ""
ts.Close
' Clean up.
Set ts = Nothing
Set fs = Nothing
End If
' ***** ----- HTML output file end ----- *****
' Message - info.
doBeep("2")
strMessageInfo = ""
strMessageInfo = strMessageInfo & "Files processed: "
strMessageInfo = strMessageInfo & CStr(intCounter)
strMessageInfo = strMessageInfo & ". Generated output "
If Lcase(strOutFileExt) = Lcase(Trim("all")) Then
strMessageInfo = strMessageInfo & "files"
Else
strMessageInfo = strMessageInfo & "file"
End If
strMessageInfo = strMessageInfo & ": " & Chr(34)
If Lcase(strOutFileExt) = Lcase(Trim("txt")) Then
'strMessageInfo = strMessageInfo & Lcase(Trim("...\PrintDir.txt"))
strMessageInfo = strMessageInfo & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt"
End If
If Lcase(strOutFileExt) = Lcase(Trim("htm")) Then
'strMessageInfo = strMessageInfo & Lcase(Trim("...\PrintDir.htm"))
strMessageInfo = strMessageInfo & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm"
End If
If Lcase(strOutFileExt) = Lcase(Trim("all")) Then
'strMessageInfo = strMessageInfo & Lcase(Trim("...\PrintDir.txt"))
strMessageInfo = strMessageInfo & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt"
strMessageInfo = strMessageInfo & Chr(34)
strMessageInfo = strMessageInfo & " and "
strMessageInfo = strMessageInfo & Chr(34)
'strMessageInfo = strMessageInfo & Lcase(Trim("...\PrintDir.htm"))
strMessageInfo = strMessageInfo & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm"
End If
strMessageInfo = strMessageInfo & Chr(34) & "."
' Show result information.
'MsgBox strMessageInfo, vbOKOnly, "Print Dir or Directory Printer"
WScript.Timeout = 10 : WScript.Echo strMessageInfo
End Sub
Function GetArguments() 'As Boolean
' Returns true if it got good arguments.
Dim fs 'As Scripting.FileSystemObject
Dim f
Dim intFileAttributeValue 'As Integer
Dim strPrompt 'As String
Dim strAddLinkToHtmFileName 'As String
Dim strSortOrderAscending 'As String
Dim strShowSiteHeaderAndFooterText 'As String
Set fs = CreateObject("Scripting.FileSystemObject")
strPrompt = ""
strAddLinkToHtmFileName = ""
strSortOrderAscending = ""
strShowSiteHeaderAndFooterText = ""
'MsgBox ("WScript.Arguments.Count = " & CStr(WScript.Arguments.Count) & ".") ' Only for the purpose of debugging.
' * * * * * - - - - - * * * * *
' Help: Arguments on the command line.
If WScript.Arguments.Count = 0 Then
MsgBox "You can enter arguments on the command line in the same order I'm going to ask you!", vbOKOnly, "Print Dir or Directory Printer"
End If
' * * * * * - - - - - * * * * *
' Get the input file path.
'If strPathIn = "" Then strPathIn = strPathIn
If WScript.Arguments.Count > 0 Then
' WScript.Arguments; zero-based index.
strPathIn = WScript.Arguments(0)
Else
strPathIn = InputBox("Enter the full path for the input file(s) i.e. the full path to the input directory or folder", "Print Dir or Directory Printer", strPathIn & "")
End If
strPathIn = Trim(strPathIn)
If strPathIn = "" Then
MsgBox "Fatal Error: No folder path entered for the input file(s).", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
If Right(strPathIn, 1) <> "\" Then
strPathIn = strPathIn & "\"
End If
If Trim(strPathIn) <> "" And Len(Trim(strPathIn)) > 1 And Mid(Trim(strPathIn), 2, 1) = ":" Then
' Force case of Drive Letter to uppercase letter.
strPathIn = UCase(CStr(Mid(Trim(strPathIn), 1, 1))) & CStr(Mid(Trim(strPathIn), 2, Len(Trim(strPathIn)) - 1))
End If
If fs.FolderExists(strPathIn) Then
' Folder exists.
Else
' Folder do *not* exists.
MsgBox "Fatal Error: No folder path to serve for the input file(s).", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
' * * * * * - - - - - * * * * *
' Get the output file path.
If strPathOut = "" Then strPathOut = strPathIn
If WScript.Arguments.Count > 1 Then
' WScript.Arguments; zero-based index.
strPathOut = WScript.Arguments(1)
Else
strPathOut = InputBox("Enter the full path for the output file(s)", "Print Dir or Directory Printer", strPathOut & "")
End If
strPathOut = Trim(strPathOut)
If strPathOut = "" Then
MsgBox "Fatal Error: No folder path entered for the output file(s).", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
If Right(strPathOut, 1) <> "\" Then
strPathOut = strPathOut & "\"
End If
If Trim(strPathOut) <> "" And Len(Trim(strPathOut)) > 1 And Mid(Trim(strPathOut), 2, 1) = ":" Then
' Force case of Drive Letter to uppercase letter.
strPathOut = UCase(CStr(Mid(Trim(strPathOut), 1, 1))) & CStr(Mid(Trim(strPathOut), 2, Len(Trim(strPathOut)) - 1))
End If
If fs.FolderExists(strPathOut) Then
' Folder exists.
Else
' Folder do *not* exists.
MsgBox "Fatal Error: No folder path to serve for the output file(s).", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
' * * * * * - - - - - * * * * *
'Get the output text/html file name(s).
If strOutFileNameExt = "" Then strOutFileNameExt = Lcase(Trim("PrintDir.txt"))
strPrompt = ""
strPrompt = strPrompt & "Enter file name of the output text file"
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & "Valid file extension(s): "
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & "For a text file: "".txt"" (default) "
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & "For a HTML file: "".htm"" "
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & "- or use "".all"" for selecting all of the valid file formats"
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & "Warning: "
strPrompt = strPrompt & vbCrLf
strPrompt = strPrompt & "Output file(s) will be overwritten if it/they exists."
If WScript.Arguments.Count > 2 Then
' WScript.Arguments; zero-based index.
strOutFileNameExt = WScript.Arguments(2)
Else
strOutFileNameExt = InputBox(strPrompt, "Print Dir or Directory Printer", strOutFileNameExt & "")
End If
strOutFileNameExt = Trim(strOutFileNameExt)
If strOutFileNameExt = "" Then
MsgBox "Fatal Error: No file name of the output text file entered.", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
strOutFileExt = ""
If InStrRev(strOutFileNameExt, ".") = 0 Then
' No file extension entered.
strOutFileExt = ""
Else
' File extension entered.
strOutFileExt = Mid(strOutFileNameExt, InStrRev(strOutFileNameExt, ".") + 1)
End If
If InStrRev(strOutFileNameExt, ".") = 0 Then
' Correct for no file extension.
strOutFileExt = "txt" ' File extension: .txt (default).
strOutFileNameExt = strOutFileNameExt & "." & strOutFileExt
End If
If InStrRev(strOutFileNameExt, ".") = Len(strOutFileNameExt) Then
' Correct for no file extension when the file name is entered ending on '.'.
strOutFileExt = "txt" ' File extension: .txt (default).
strOutFileNameExt = strOutFileNameExt & strOutFileExt
End If
If Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) = "" Then
' No file name entered.
MsgBox "Fatal Error: File name of the output text file entered with only the file extension.", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
If Lcase(strOutFileExt) = Lcase(Trim("txt")) _
Or Lcase(strOutFileExt) = Lcase(Trim("htm")) _
Or Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is supported.
Else
' File extension is *not* supported.
MsgBox "Fatal Error: File extension of the output text file is not supported.", vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
'MsgBox ("strOutFileNameExt = """ & strOutFileNameExt & """") ' Only for the purpose of debugging.
'MsgBox ("strOutFileExt = """ & strOutFileExt & """.") ' Only for the purpose of debugging.
'MsgBox ("File name: """ & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & """.") ' Only for the purpose of debugging.
If Lcase(strOutFileExt) = Lcase(Trim("txt")) Or Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is 'txt' or 'all'.
If Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is 'all'.
On Error Resume Next
fs.OpenTextFile((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt"), 2, True).Close ' Try to create the file.
On Error Goto 0
Else
' File extension is 'txt'.
On Error Resume Next
fs.OpenTextFile((strPathOut & strOutFileNameExt), 2, True).Close ' Try to create the file.
On Error Goto 0
End If
If Not (fs.FileExists((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt"))) Then
' Make sure the output file is created.
MsgBox ("Fatal Error: Sorry, I couldn't create a file named """ & (strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt") & """."), vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
' Make sure it is possible to write to the output file and
' make sure it has been possible to create a new instance
' of the output file.
Set f = fs.GetFile((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt"))
' Attributes of files or folders:
' Constant Value Description
' Normal 0 Normal file. No attributes are set.
' ReadOnly 1 Read-only file. Attribute is read/write.
' Hidden 2 Hidden file. Attribute is read/write.
' System 4 System file. Attribute is read/write.
' Volume 8 Disk drive volume label. Attribute is read-only.
' Directory 16 Folder or directory. Attribute is read-only.
' Archive 32 File has changed since last backup. Attribute is read/write.
' Alias 1024 Link or shortcut. Attribute is read-only.
' Compressed 2048 Compressed file. Attribute is read-only.
intFileAttributeValue = f.Attributes
'MsgBox ("intFileAttributeValue = " & CStr(intFileAttributeValue)) ' Only for the purpose of debugging.
' Clean up.
Set f = Nothing
If intFileAttributeValue = 0 Or intFileAttributeValue = 32 Then
' It is possible to write to the output file and
' it has therefore also been possible to create a
' new instance of the output file.
Else
' It is *not* possible to write to the output file and
' it has therefore also *not* been possible to create a
' new instance of the output file.
MsgBox ("Fatal Error: Sorry, I couldn't write to or create a new file named """ & (strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "txt") & """."), vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
End If
If Lcase(strOutFileExt) = Lcase(Trim("htm")) Or Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is 'htm' or 'all'.
If Lcase(strOutFileExt) = Lcase(Trim("all")) Then
' File extension is 'all'.
On Error Resume Next
fs.OpenTextFile((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm"), 2, True).Close ' Try to create the file.
On Error Goto 0
Else
' File extension is 'htm'.
On Error Resume Next
fs.OpenTextFile((strPathOut & strOutFileNameExt), 2, True).Close ' Try to create the file.
On Error Goto 0
End If
If Not (fs.FileExists((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm"))) Then
' Make sure the output file is created.
MsgBox ("Fatal Error: Sorry, I couldn't create a file named """ & (strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm") & """."), vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
' Make sure it is possible to write to the output file and
' make sure it has been possible to create a new instance
' of the output file.
Set f = fs.GetFile((strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm"))
' Attributes of files or folders:
' Constant Value Description
' Normal 0 Normal file. No attributes are set.
' ReadOnly 1 Read-only file. Attribute is read/write.
' Hidden 2 Hidden file. Attribute is read/write.
' System 4 System file. Attribute is read/write.
' Volume 8 Disk drive volume label. Attribute is read-only.
' Directory 16 Folder or directory. Attribute is read-only.
' Archive 32 File has changed since last backup. Attribute is read/write.
' Alias 1024 Link or shortcut. Attribute is read-only.
' Compressed 2048 Compressed file. Attribute is read-only.
intFileAttributeValue = f.Attributes
'MsgBox ("intFileAttributeValue = " & CStr(intFileAttributeValue)) ' Only for the purpose of debugging.
' Clean up.
Set f = Nothing
If intFileAttributeValue = 0 Or intFileAttributeValue = 32 Then
' It is possible to write to the output file and
' it has therefore also been possible to create a
' new instance of the output file.
Else
' It is *not* possible to write to the output file and
' it has therefore also *not* been possible to create a
' new instance of the output file.
MsgBox ("Fatal Error: Sorry, I couldn't write to or create a new file named """ & (strPathOut & Mid(strOutFileNameExt, 1, InStrRev(strOutFileNameExt, ".") - 1) & "." & "htm") & """."), vbOKOnly, "Print Dir or Directory Printer"
GetArguments = False
Exit Function
End If
End If
' * * * * * - - - - - * * * * *
' Get the add link to htm file name(s).
'bAddLinkToHtmFileName = False ' Add link to htm file name(s) ('True' or 'False') [Default: False].
If WScript.Arguments.Count > 3 Then
' WScript.Arguments; zero-based index.
strAddLinkToHtmFileName = Lcase(Trim( WScript.Arguments(3) ))
Select Case strAddLinkToHtmFileName
Case "yes"
' Mode: Do add link to htm file name(s).
bAddLinkToHtmFileName = True
Case "no"
' Mode: Do not add link to htm file name(s). [Default]
bAddLinkToHtmFileName = False
Case Else
' Error.
bAddLinkToHtmFileName = False ' Add link to htm file name(s) ('True' or 'False') [Default: False].
End Select
Else
'If MsgBox("Add link to ""htm"" or ""html"" file name(s) if output text file is a HTML file?", vbYesNo, "Print Dir or Directory Printer") = vbNo Then
If MsgBox("Add link to ""htm"" or ""html"" file name(s) if output text file is a HTML file?", vbYesNo + VbQuestion + vbDefaultButton2, "Print Dir or Directory Printer") = vbNo Then
' Mode: Do not add link to htm file name(s). [Default]
bAddLinkToHtmFileName = False
Else
' Mode: Do add link to htm file name(s).
bAddLinkToHtmFileName = True
End If
End If
' * * * * * - - - - - * * * * *
' Get the sort order.
'bSortOrderAscending = True ' Sort order selected by specifying the sort criteria 'Sort Ascending [A-Z]' (True) or 'Sort Descending [Z-A]' (False) [Default: True].
If WScript.Arguments.Count > 4 Then
' WScript.Arguments; zero-based index.
strSortOrderAscending = Lcase(Trim( WScript.Arguments(4) ))
Select Case strSortOrderAscending
Case "yes"
' Mode: Use sort criteria 'Sort Ascending [A-Z]' (True). [Default]
bSortOrderAscending = True
Case "no"
' Mode: Use sort criteria 'Sort Descending [Z-A]' (False).
bSortOrderAscending = False
Case Else
' Error.
bSortOrderAscending = True ' Sort order selected by specifying the sort criteria 'Sort Ascending [A-Z]' (True) or 'Sort Descending [Z-A]' (False) [Default: True].
End Select
Else
'If MsgBox("Use sort criteria 'Sort Ascending [A-Z]' (Yes) or 'Sort Descending [Z-A]' (No)?", vbYesNo, "Print Dir or Directory Printer") = vbYes Then
If MsgBox("Use sort criteria 'Sort Ascending [A-Z]' (Yes) or 'Sort Descending [Z-A]' (No)?", vbYesNo + VbQuestion + vbDefaultButton1, "Print Dir or Directory Printer") = vbYes Then
' Mode: Use sort criteria 'Sort Ascending [A-Z]' (True). [Default]
bSortOrderAscending = True
Else
' Mode: Use sort criteria 'Sort Descending [Z-A]' (False).
bSortOrderAscending = False
End If
End If
' * * * * * - - - - - * * * * *
' Get the show site header and footer text.
'bShowSiteHeaderAndFooterText = True ' Show site header and footer text ('True' or 'False') [Default: True].
If WScript.Arguments.Count > 5 Then
' WScript.Arguments; zero-based index.
strShowSiteHeaderAndFooterText = Lcase(Trim( WScript.Arguments(5) ))
Select Case strShowSiteHeaderAndFooterText
Case "yes"
' Mode: Do show site header and footer text. [Default]
bShowSiteHeaderAndFooterText = True
Case "no"
' Mode: Do not show site header and footer text.
bShowSiteHeaderAndFooterText = False
Case Else
' Error.
bShowSiteHeaderAndFooterText = True ' Show site header and footer text ('True' or 'False') [Default: True].
End Select
Else
'If MsgBox("Show site header and footer text?", vbYesNo, "Print Dir or Directory Printer") = vbYes Then
If MsgBox("Show site header and footer text?", vbYesNo + VbQuestion + vbDefaultButton1, "Print Dir or Directory Printer") = vbYes Then
' Mode: Do show site header and footer text. [Default]
bShowSiteHeaderAndFooterText = True
Else
' Mode: Do not show site header and footer text.
bShowSiteHeaderAndFooterText = False
End If
End If
' * * * * * - - - - - * * * * *
' Clean up.
Set fs = Nothing
' Everything worked!
GetArguments = True
End Function
'Public Function doBubbleSortMyList(ByVal SortList(), bDoSortListItems As Boolean, sUseSortOrder As String, bUseStandardSortAlgorithm As Boolean)
'Public Function doBubbleSortMyList(ByRef SortList As Variant, bDoSortListItems As Boolean, sUseSortOrder As String, bUseStandardSortAlgorithm As Boolean)
Public Function doBubbleSortMyList(ByRef SortList, bDoSortListItems, sUseSortOrder, bUseStandardSortAlgorithm)
' Bubble Sort My List.
' This function assumes it's passed an Array or a Dynamic Array,
' and bubble sorts the list elements in the passed array, which
' is returned as an 'Array'.
' Bubble Sort.
' The array-oriented sort routine bubble sort greatest virtue
' is its simplicity. It is very fast on nearly sorted items, but
' its general performance is relatively poor. The bubble sort
' algorithm is very simple: successive sweeps are made through
' the items to be sorted, and on each sweep the largest item is
' moved closer to the top, rising slowly like a bubble - hence
' the name. Because each sweep places one item into its final
' and correct position, the next sweep need not re-examine this
' item. For the sorting of the items is used an array of 'n'
' items. An analysis of the order of this algorithm is
' straightforward: it makes 'n' passes through the items, and
' on each pass it performs 'n'-1 comparisons and possibly this
' number of swaps. Thus, the algorithm's running time will be
' proportional to 'n'('n'-1), or more simply just 'n'2. The code
' takes advantage of the fact that if no swaps are made on any
' given pass, the items are sorted and the sort can terminate.
'
' Note that if an array's items (elements) are in text string
' variables and all consist of integer numbers or floating-point
' numbers you can with advantage use the built-in function
' 'CInt()', CLng()' or 'CDbl()' to parse the string arguments
' to the appropriate number type variables from the array before
' a sort comparison is performed - otherwise the sort order of
' the numbers will not be correct.
'
' Note: All parameters (variables) passed to this function must
' be valid - no error checking is performed.
'
' SortList(): Array to sort - Note: Variable passed must be a
' valid array object whose property ('length') contains the
' number of items (elements) in the 'dense' array, which is
' one in which each item (element) has an integer value. Base
' must be an integer with a value of '0' (default; zero-based index)
' or '1' (index base 1).
' startingIndexBaseInteger: The 'dense' array's starting index - Integer
' with a value of '0' (default; zero-based index) or '1' (index base 1).
' sortDirectionString: The direction of the sort - String
' ('Ascending' [A-Z, zero to 9] (default) or 'Descending' [Z-A, 9 to zero]).
'
' Define variables.
Dim IntValue 'As Long
Dim IntIntValue 'As Long
Dim startingIndexBaseInteger 'As Integer
Dim sortDirectionString 'As String
Dim SortOrder 'As String
Dim StartLbound 'As Long
Dim EndUbound 'As Long
Dim swapped 'As Boolean
Dim tmpStr 'As String ' Temporary text.
'If IsNull(SortList()) = True Then
If IsNull(SortList) = True Then
'doBubbleSortMyList = SortList()
Exit Function
End If
If bDoSortListItems = False Then
'doBubbleSortMyList = SortList()
Exit Function
End If
' Initialize variables.
startingIndexBaseInteger = 0 ' default; zero-based index. Note: This function uses the default value.
'StartLbound = LBound(SortList())
StartLbound = LBound(SortList)
'EndUbound = UBound(SortList())
EndUbound = UBound(SortList)
swapped = False ' Stores state for if a swap is made - Boolean value.
tmpStr = "" ' Temporary text.
If EndUbound < 1 Then
' Make sure there is at least two items (elements) in the array - otherwise
' return the passed variable (array object) unprocessed - no sorting necessary.
'doBubbleSortMyList = SortList()
Exit Function
End If
' Make sure of the variable value if 'nothing' is the contents of the input or
' it is not an integer with a value of '0' (default; zero-based index) or
' '1' (index base 1) - otherwise use the default value.
If IsNumeric(startingIndexBaseInteger) = True Then
startingIndexBaseInteger = CInt(startingIndexBaseInteger) ' Force string to a number.
Else
startingIndexBaseInteger = 0
End If
If startingIndexBaseInteger <> 0 And startingIndexBaseInteger <> 1 Then
startingIndexBaseInteger = 0 ' Default value (zero-based index).
End If
If IsNull(sUseSortOrder) = True Then
sortDirectionString = ""
Else
sortDirectionString = sUseSortOrder
End If
' Sort order selected by the value of 'sortDirectionString' specifying the sort criteria.
' [Danish] Sorteringsraekkefoelge valgt ved vaerdien af 'sortDirectionString' bestemmende sorteringskriteriet.
If LCase(sortDirectionString) = LCase("Ascending") Or LCase(sortDirectionString) = LCase("Stigende") Then
' Sort criteria: 'Sort Ascending [A-Z, zero to 9]' (Ascending).
' [Danish] Sorteringskriterie: Sorter stigende [A-Z, nul til 9] (Stigende).
SortOrder = "Ascending"
ElseIf LCase(sortDirectionString) = LCase("Descending") Or LCase(sortDirectionString) = LCase("Faldende") Then
' Sort criteria: 'Sort Descending [Z-A, 9 to zero]' (Descending).
' [Danish] Sorteringskriterie: Sorter faldende [Z-A, 9 til nul] (Faldende).
SortOrder = "Descending"
Else
' In all other cases chose the default setting [Default: Ascending].
' [Danish] I alle andre tilfaelde vaelg standard indstilling [Standard: Stigende].
SortOrder = "Ascending"
End If
' Sort array items (elements) - only if there is more than one item (element) in the array.
' The 'dense' array's property ('UBound()') contains the number of items (elements) in
' the array, which must be starting with index 0 (zero-based index) or 1 (index base 1).
' Perform the actual sort of the items (elements) in the array based on the value
' of the variable 'SortOrder' (string).
If SortOrder = "Ascending" Then
' Sort Ascending [A-Z, zero to 9] (default).
' Bubble sort an array - Ascending.
If bUseStandardSortAlgorithm = True Then
' Use Standard Sort Algorithm.
swapped = False ' Stores state for if a swap is made - Boolean value.
' Make steadily shorter passes...
For IntValue = EndUbound To StartLbound Step -1 ' Start the loop.
' On each pass, sweep *largest* element to end of array.
swapped = False ' Not done sort swap.
For IntIntValue = StartLbound To (EndUbound - 1) Step 1
If SortList(IntIntValue) > SortList(IntIntValue + 1) Then
tmpStr = SortList(IntIntValue)
SortList(IntIntValue) = SortList(IntIntValue + 1)
SortList(IntIntValue + 1) = tmpStr
swapped = True ' Done sort swap.
End If
Next 'IntIntValue
If swapped = False Then
Exit For ' If no swaps, we have finished.
End If
Next 'IntValue
Else
' Use Customized Sort Algorithm.
swapped = False ' Stores state for if a swap is made - Boolean value.
' Make steadily shorter passes...
For IntValue = EndUbound To StartLbound Step -1 ' Start the loop.
' On each pass, sweep *largest* element to end of array.
swapped = False ' Not done sort swap.
For IntIntValue = StartLbound To (EndUbound - 1) Step 1
If LCase(SortList(IntIntValue)) > LCase(SortList(IntIntValue + 1)) Then
tmpStr = SortList(IntIntValue)
SortList(IntIntValue) = SortList(IntIntValue + 1)
SortList(IntIntValue + 1) = tmpStr
swapped = True ' Done sort swap.
End If
Next 'IntIntValue
If swapped = False Then
Exit For ' If no swaps, we have finished.
End If
Next 'IntValue
End If
ElseIf SortOrder = "Descending" Then
' Sort Descending [Z-A, 9 to zero].
' Bubble sort an array - Descending.
If bUseStandardSortAlgorithm = True Then
' Use Standard Sort Algorithm.
swapped = False ' Stores state for if a swap is made - Boolean value.
' Make steadily shorter passes...
For IntValue = EndUbound To StartLbound Step -1 ' Start the loop.
' On each pass, sweep *largest* element to end of array.
swapped = False ' Not done sort swap.
For IntIntValue = StartLbound To (EndUbound - 1) Step 1
If SortList(IntIntValue) < SortList(IntIntValue + 1) Then
tmpStr = SortList(IntIntValue)
SortList(IntIntValue) = SortList(IntIntValue + 1)
SortList(IntIntValue + 1) = tmpStr
swapped = True ' Done sort swap.
End If
Next 'IntIntValue
If swapped = False Then
Exit For ' If no swaps, we have finished.
End If
Next 'IntValue
Else
' Use Customized Sort Algorithm.
swapped = False ' Stores state for if a swap is made - Boolean value.
' Make steadily shorter passes...
For IntValue = EndUbound To StartLbound Step -1 ' Start the loop.
' On each pass, sweep *largest* element to end of array.
swapped = False ' Not done sort swap.
For IntIntValue = StartLbound To (EndUbound - 1) Step 1
If LCase(SortList(IntIntValue)) < LCase(SortList(IntIntValue + 1)) Then
tmpStr = SortList(IntIntValue)
SortList(IntIntValue) = SortList(IntIntValue + 1)
SortList(IntIntValue + 1) = tmpStr
swapped = True ' Done sort swap.
End If
Next 'IntIntValue
If swapped = False Then
Exit For ' If no swaps, we have finished.
End If
Next 'IntValue
End If
Else
' Do nothing.
'MsgBox("Do nothing.", (0 + 64), "Info") ' Only for the purpose of debugging.
'MsgBox prompt:="Do nothing.", _
'Title:="Info", buttons:=vbInformation + vbOKOnly ' Only for the purpose of debugging.
End If
'doBubbleSortMyList = SortList()
End Function
Function LongName(strFullPathAndFile) 'As String
' Converts a legitimate short file name into the long file name.
Dim strOriginalFile 'As String
Dim fs, fil, fils, fol
Dim blnFound 'As Boolean
Set fs = CreateObject("Scripting.FileSystemObject")
blnFound = False
strOriginalFile = fs.GetFile(strFullPathAndFile).ShortPath
Set fol = fs.GetFolder(fs.GetParentFolderName(strFullPathAndFile))
Set fils = fol.Files
For Each fil In fils
If fil.ShortPath = strOriginalFile Then
strOriginalFile = fil.Path
blnFound = True
Exit For
End If
Next
If blnFound Then
LongName = strOriginalFile
Else
LongName = strFullPathAndFile
End If
'MsgBox ("LongName = " & LongName) ' Only for the purpose of debugging.
' Clean up.
Set fils = Nothing
Set fol = Nothing
Set fs = Nothing
End Function
Sub Force(sScriptEng)
' Forces this script to be run under the desired scripting host.
' Valid sScriptEng arguments are "wscript" or "cscript".
' If you don't supply a valid name, Force will switch hosts...
If Lcase(Right(Wscript.FullName, 12)) = "\wscript.exe" Then
' Running under WSCRIPT.
If Instr(1, Wscript.FullName, sScriptEng, 1) = 0 Then
' Need to switch to CSCRIPT.
CreateObject("Wscript.Shell").Run "cscript.exe " & Wscript.ScriptFullName
Wscript.Quit
End If
Else
' Running under CSCRIPT.
If Instr(1, Wscript.FullName, sScriptEng, 1) = 0 Then
' Need to switch to WSCRIPT
CreateObject("Wscript.Shell").Run "wscript.exe " & Wscript.ScriptFullName
Wscript.Quit
End If
End If
End Sub
'Public Function doFormatNum(lngNum As Long, intLen As Integer) As String
Public Function doFormatNum(lngNum, intLen)
' This function assumes it's passed an integer number
' and add missing leading zero's in front of the number,
' which is returned as a 'string' type number.
' Define variables.
Dim strNum 'As String
If IsNull(lngNum) = True Then
doFormatNum = CStr(0)
Exit Function
End If
' Initialize variables.
strNum = CStr(lngNum) ' Convert number to a string.
Do While Len(strNum) < intLen ' Start the loop.
strNum = "0" & strNum
Loop
doFormatNum = strNum
End Function
Function doBeep(iTimes)
'#--------------------------------------------------------------------------
'# FUNCTION.......: doBeep()
'# ARGUMENTS......: iTimes = the number of times the computer will beep.
'# PURPOSE........: Causes the computer's internal speaker to beep. On
'# some systems the beep will be executed from the actual
'# speakers.
'# EXAMPLE........: doBeep("7")
'# NOTES..........: This was surprisingly hard to figure out, yet highly
'# useful. There is a timing issue, the script will
'# execute the beeps faster than the speaker can make
'# individual noises.
'#--------------------------------------------------------------------------
' Define variables.
Dim oShell
Set oShell = CreateObject("Wscript.Shell")
Dim iTemp 'As Integer ' Iterator for loops.
For iTemp = 1 To CInt(iTimes) Step 1
oShell.Run "%comspec% /c echo " & Chr(7), 0, False
Wscript.Sleep 300
Next
' Clean up.
Set oShell = Nothing
End Function
Conventions used for: Source code syntax highlighting. / Regler brugt til: Kildekode syntaks fremhævning.
Simple word processor: / Simpel tekstbehandlerprogram:
printdir.vbs
/ printdir.vbs
.txt
to the saved file .txt
til den gemte fil
Or: / Eller:
Right-click the script file name and choose "Send to" -
"Desktop (make shortcut)". Right-click the "PrintDir"
desktop icon and choose "Properties". Then select the
tap "Shortcut" and the input field "Destination" and
add the parameters (all parameters must be specified in
double quotes): /
Højre-klik på skript filnavnet og vælg "Send til" -
"Skrivebord (opret genvej)". Højre-klik på "PrintDir"
skrivebordsikonet og vælg "Egenskaber". Vælg så
fanen "Genvej" og indtastningsfeltet "Destination" og
tilføj parametrene (alle parametre skal angives i
dobbelt citationstegn):
(full path to)printdir.vbs "C:\test\myTest" "C:\test\mytest" "printdir.txt|printdir.htm|printdir.all" "Yes|No" "Yes|No" "Yes|No"
/
(fuld sti til)printdir.vbs "C:\test\myTest" "C:\test\mytest" "printdir.txt|printdir.htm|printdir.all" "Yes|No" "Yes|No" "Yes|No"
Conventions used for: Source code syntax highlighting. / Regler brugt til: Kildekode syntaks fremhævning.
where the parameters (in order)
1. parameter: Enter the full path for the input file(s) i.e. the full path to the input directory or folder /
1. parameter: Indtast den fulde sti for input fil(er), dvs. den fulde sti til input bibliotek eller mappe
2. parameter: Enter the full path for the output file(s) /
2. parameter: Indtast den fulde sti til output-fil(er)
3. parameter: Enter file name of the output text file
Valid file extension(s):
For a text file: ".txt" (default)
For a HTML file: ".htm"
- or use ".all" for selecting all of the valid file formats
Warning:
Output file(s) will be overwritten if it/they exists.
/
3. parameter: Indtast filnavnet på output tekstfil
Gyldig filtypenavn(e):
For en tekstfil: ".txt" (standard)
For en HTML-fil: ".htm"
- eller brug ".all" til at vælge alle de gyldige filformater
Advarsel:
Output-fil(er) vil blive overskrevet, hvis den/de eksisterer.
4. parameter: Add link to "htm" or "html" file name(s) if output text file is a HTML file? (Default: No) - Valid values: Yes|No /
4. parameter: Tilføj link til "htm" eller "html" filnavn(e), hvis output tekstfil er en HTML-fil? (Standard: Nej) - Gyldige værdier: Yes|No
5. parameter: Use sort criteria 'Sort Ascending [A-Z]' (Yes) or 'Sort Descending [Z-A]' (No)? (Default: Yes) - Valid values: Yes|No /
5. parameter: Brug sorteringskriterie 'Sorter stigende [A-Z]' (Ja) eller 'Sorter faldende [Z-A]' (Nej)? (Standard: Ja) - Gyldige værdier: Yes|No
6. parameter: Show site header and footer text? (Default: Yes) - Valid values: Yes|No /
6. parameter: Vis websted sidehoved og sidefod tekst? (Standard: Ja) - Gyldige værdier: Yes|No
You can download a version of the source code from my Download page here: / Du kan downloade en version af kildekoden fra min Download side her:
[VBS] Download "Print Dir or Directory Printer" 'printdir.vbs' for VBScript & WSH COM object "WScript": printdir.zip / [VBS] Download "Print Dir eller Directory Printer" 'printdir.vbs' for VBScript & WSH COM objekt "WScript": printdir.zip
The code might need some minor tweaks to run in your application. / Koden kan behøve nogle mindre ændringer for at kunne afvikles i dit anvendelsesområde.
Licence: Free to use, but please
share improvements.
No warranty - use at own risk. /
Licens: Fri brug, men
del venligst forbedringer.
Ingen garanti - brug på eget ansvar.
Warning: Don't run the script files
without reading them first!
Total absence of any guarantee, warranty, or
responsibility for script files, the script(s), the files they
may produce, or the effects the script(s) or script-produced
files may have. The script(s) is, after all, plain text. The
burden is on the person using the script(s) to examine
the script source code and determine whether or not a script is
usable and safe. Operating systems and browsers are constantly
changing. What works today may not work tomorrow!
Advarsel: Kør ikke script-filerne
uden at læse dem først!
Totalt fravær af nogen form for garanti,
garanti eller ansvar for script-filer, scriptet(scriptene), de
filer, de kan producere eller de virkninger, scriptet(scriptene)
eller scriptproducerede filer kan have. Scriptet(Scriptene) er,
trods alt, almindelig tekst. Byrden er på brugeren af
scriptet(scriptene) til at undersøge script kildekoden og
afgøre, hvorvidt et script er brugbart og sikkert.
Operativsystemer og browsere er under konstant forandring. Hvad
fungerer i dag, fungerer muligvis ikke i morgen!
|