----- Original Message ----- From: "Paul A Norman" <[EMAIL PROTECTED]>
To: "NZ Borland Developers Group - Offtopic List" <[EMAIL PROTECTED]>
Sent: Thursday, 23 September 2004 10:50 p.m.
Subject: Re: [DUG-Offtopic] Making a text file of directory contents?


chgange the attached files as indicated back to their proper extensions,
hopefully this will get past server filemunchers.

You may need to add a switch or two or the dir will have too much info on
each line and extra stuff elsewhere

 dir /b *.mp3 >mpXlist.txt
 dir /b *.mp4 >> mpXlist.txt
. . . etc.

Would append the second lot of stuff to the mpXlist.txt as well

if you want to do it from delphi try this, just alter it for your file
type(s) this (below) was a console application  for graphics (can run from
dos). I used dos insteads of findfirst etc as I still sometimes find dos
more straight foraward! When spare time comes along I intend to add a
floating directory index TOC.

It makes a list of graphics  from a chosen directory (and subdirectories)
and produces it in an HTML and shows the page in the browser useful for
exploring legacy or transfered web pages on disk., You could make such a
thing  useful on a CDROM with Autorun.inf (a text file) and a shellexe.exe
as the open=

Make sure that shellexe.exe is in the root of the cdrom with the autorun.inf
file and the index.htm you make!

autorun.inf

[autorun]
open=shellexe.exe index.htm

=====================================================================

program imageToHtml;

{$APPTYPE CONSOLE}

{Paul A. Norman P.O. Box 1005 Nelson 7015 New Zealand, email
[EMAIL PROTECTED]
Thanks to Peter Below Team B for Win32 Apis and Michael Cassena for the
compilation}

uses
 SysUtils,
 shellapi,
 windows,
 classes,
 filectrl,
 dialogs ;


var

 batFile,  filelist, htmlDisplay : tstringlist  ;
 baseDirectory, progDirectory, imageToHtmlTxt :string;

  function GetDOSPathname( const longname: String ): String;
  begin
  SetLength(Result, Length(longname));
  SetLength(
    Result,
    GetShortPathname( @longname[1], @result[1], length(result)));
  end;


procedure setUp; begin batFile := tstringlist.Create ; filelist := tstringlist.Create ; htmlDisplay := tstringlist.Create ; progDirectory := extractfiledir(ParamStr(0)) ; // showmessage(progDirectory); imageToHtmlTxt := GetDOSPathname(progDirectory)+'\imageToHtml.txt'; // showmessage(imageToHtmlTxt); end;

procedure finishUp;
begin
    batFile.Free;
    fileList.Free;
    htmlDisplay.Free;
end;

function WinExecAndWait32(FileName:String; Visibility : integer):integer;
 var  { by Pat Ritchey }
   zAppName:array[0..512] of char;
   StartupInfo:TStartupInfo;
   ProcessInfo:TProcessInformation;
   xx : cardinal;
 begin
   StrPCopy(zAppName,FileName);
   FillChar(StartupInfo,Sizeof(StartupInfo),#0);
   StartupInfo.cb := Sizeof(StartupInfo);
   StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
   StartupInfo.wShowWindow := Visibility;
   if not CreateProcess(nil,
     zAppName,                      { pointer to command line string }
     nil,                           { pointer to process security
attributes
}
     nil,                           { pointer to thread security
attributes }
     false,                         { handle inheritance flag }
     CREATE_NEW_CONSOLE or          { creation flags }
     NORMAL_PRIORITY_CLASS,
     nil,                           { pointer to new environment block
}
     nil,                           { pointer to current directory
name }
     StartupInfo,                   { pointer to STARTUPINFO }
     ProcessInfo) then Result := -1 { pointer to PROCESS_INF }
   else
      begin
      WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
      GetExitCodeProcess(ProcessInfo.hProcess,xx);
      CloseHandle( ProcessInfo.hProcess );
      CloseHandle( ProcessInfo.hThread );
      result := xx;
      end;
 end;

 procedure makeAndShowHtml;
 var
  count : integer;
  holdPath :string;
 begin

    htmlDisplay.Add('<Html><Head><Title>'
                    +'Images For: '+baseDirectory +' And Subdirectories'
                    +'</title></head><body style="margin:50px">'
                    +'<h2>Images For "'+baseDirectory+'" And Sub
Directories</h2>'
                    +'<h2>Clear the Security and Click Any Image to See it
in its Own Window</h2>'
                    +'<p style="text-align:center; font-weight:bold" >List
of Images</p>'
                    +'<iframe src="'+imageToHtmlTxt+'" style="left:-50"
width="750" height="150"></iframe>') ;
      holdPath := extractfiledir(fileList[0]);
    for count := 0 to fileList.Count -1 do
      begin

          if holdPath <> extractfiledir(fileList[count])
           then
            begin
                holdPath := extractfiledir(fileList[count]);
                htmlDisplay.Add('<h2>Directory:  '+holdPath +'</h2>');
            end;

         htmlDisplay.Add('<p /><span
style="font-size:10pt;font-family:arial, sans-serif">'+ fileList[count]
+'</span>'
                         +'<br /><img title="[Click for Own Window At
Actual Size]" src="'+fileList[count]+'" width="150"
onclick="window.open(this.src)" />') ;
      end;
    htmlDisplay.Add('</body></html>');
    htmlDisplay.SaveToFile(progDirectory+'\imageToHtml.html');
    shellexecute(
GetForegroundWindow,pchar('open'),pchar(progDirectory+'\imageToHtml.html'),'','',sw_normal);
 end;

 begin
 setUp;
 baseDirectory := ParamStr(1);
 if not SelectDirectory('Please Choose The Base Directory for the Web
Images'
                         +#13
                         +' Wriiten for Free Use -
http://PaulANorman.com','',baseDirectory)
     then
      begin
     showmessage('You Cancelled Image Listing');
     exit;
      end;

 //showMessage(baseDirectory);
 { TODO -oUser -cConsole Main : Insert code here }

 batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.gif'+' >
'+imageToHtmlTxt)  ;
  batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.jpg'+' >>
'+imageToHtmlTxt)  ;
  batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.jpeg'+'  >>
'+imageToHtmlTxt)  ;
   batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.png'+'  >>
'+imageToHtmlTxt)  ;
    batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.emf'+'  >>
'+imageToHtmlTxt)  ;
   batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.wmf'+'  >>
'+imageToHtmlTxt)  ;
  batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.bmp'+'  >>
'+imageToHtmlTxt)  ;
 batFile.Add('dir /s /b '+GetDOSPathname(baseDirectory)+'\*.xbm'+'  >>
'+imageToHtmlTxt)  ;

 batFile.SaveToFile(progDirectory+'\imageToHtml.bat');
 WinExecAndWait32(GetDOSPathname(progDirectory)+'\imageToHtml.bat',
sw_hide);
 fileList.LoadFromFile(imageToHtmlTxt);
 filelist.Sorted := true;
 makeAndShowHtml;
 finishUp;

end.

==================================

----- Original Message ----- From: "Kyley Harris" <[EMAIL PROTECTED]>
To: "NZ Borland Developers Group - Offtopic List" <[EMAIL PROTECTED]>
Sent: Thursday, 23 September 2004 8:53 p.m.
Subject: Re: [DUG-Offtopic] Making a text file of directory contents?



in a dos prompt

c:\dir *.mp3 > mp3list.txt

this will output the command to mp3list.txt by using the > token

Colin/Mina wrote:

Hi,

I want to create a text file of the file names in a folder to ultimately
insert into a CD cover via Word or some other application.

 I seem to remember doing it years ago in DOS by accident but I can't
reproduce the effect.

 Please can somone suggest how to do it.

Cheers

     Colin



_______________________________________________
Offtopic mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/offtopic


_______________________________________________
Offtopic mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/offtopic

Attachment: shellexe.z-i-p
Description: Binary data

_______________________________________________
Offtopic mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/offtopic

Reply via email to