GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/JimMartinson/_Archive/CST1861/CST1861/ |
Upload File : |
@echo off :: display.cmd :: Written by: Jim Martinson :: Written on: 2010/05/13 :: I cannot display some lines from text files using a standard .cmd script. :: Characters like | > < & % and ^ have special meaning and cause errors. :: In order to display lines from the file a .vbs script is created and run. :: Test if command line extensions are enabled. if "%~1"=="~1" goto:ExtensionsAreNotEnabled :: Display help when the /? parameter is passed. if NOT "%~1"=="/?" goto SkipHelp :Help echo Display lines from a text file. echo. echo Usage: %~n0 filename [start [stop]] [/r^|/s] echo. echo filename = The name of the file to display lines from. echo start = The starting line. Default is line 1. echo stop = The line to stop at. Default is the end of the file. echo. goto:EOF :ExtensionsAreNotEnabled echo Command line extensions are not enabled. They must be enabled for %~n0 to work properly. echo %~n0 aborted. echo. goto:Help :SkipHelp setlocal set _filename=%~1 set _start=%~2 if defined _start ( set _stop=%~3 ) else ( set _start=1 set _stop= ) if NOT defined _stop set _stop=99999 set /a _skip = _start-1 call:getLongFilename "%_filename%" :: Create a .vbs script to display the lines from the file. echo ' %~n0.vbs Will display lines %_start% through %_stop% in %_filename%.>%temp%\%~n0.vbs echo. >>%temp%\%~n0.vbs echo ' Initialaze >>%temp%\%~n0.vbs echo startLine = %_start% >>%temp%\%~n0.vbs echo endLine = %_stop% >>%temp%\%~n0.vbs echo. >>%temp%\%~n0.vbs echo ' Open %_filename% for reading. >>%temp%\%~n0.vbs echo Const ForReading = 1 >>%temp%\%~n0.vbs echo Set objFSO = CreateObject("Scripting.FileSystemObject") >>%temp%\%~n0.vbs echo Set objTextFile = objFSO.OpenTextFile ("%_filename%", ForReading) >>%temp%\%~n0.vbs echo. >>%temp%\%~n0.vbs echo ' Read the file. >>%temp%\%~n0.vbs echo Dim arrFileLines() >>%temp%\%~n0.vbs echo maxLine = 0 >>%temp%\%~n0.vbs echo Do Until objTextFile.AtEndOfStream >>%temp%\%~n0.vbs echo Redim Preserve arrFileLines(maxLine) >>%temp%\%~n0.vbs echo arrFileLines(maxLine) = objTextFile.ReadLine >>%temp%\%~n0.vbs echo maxLine = maxLine + 1 >>%temp%\%~n0.vbs echo Loop >>%temp%\%~n0.vbs echo if endLine ^> maxLine then endLine = maxLine >>%temp%\%~n0.vbs echo objTextFile.Close >>%temp%\%~n0.vbs echo. >>%temp%\%~n0.vbs echo ' Display the lines. >>%temp%\%~n0.vbs echo For i = startLine to endLine >>%temp%\%~n0.vbs echo outputText = i ^& ": " ^& arrFileLines(i) >>%temp%\%~n0.vbs echo if i ^< 10 then outputText = " " ^& outputText >>%temp%\%~n0.vbs echo if i ^< 100 then outputText = " " ^& outputText >>%temp%\%~n0.vbs echo if i ^< 1000 then outputText = " " ^& outputText >>%temp%\%~n0.vbs echo 'if i ^< 10000 then outputText = " " ^& outputText >>%temp%\%~n0.vbs echo 'if i ^< 100000 then outputText = " " ^& outputText >>%temp%\%~n0.vbs echo Wscript.Echo outputText >>%temp%\%~n0.vbs echo Next >>%temp%\%~n0.vbs :: Run the script cscript //Nologo %temp%\%~n0.vbs :: Delete the script del %temp%\%~n0.vbs goto:EOF :getLongFilename set _filename=%~f1 goto:EOF