Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

command line program

Posted on 1999-07-15
6
Medium Priority
?
146 Views
Last Modified: 2010-04-06
i need it urgent
it's for my exam
i need command line program that reads the directory (dir name given in the command line) and shows the size of the current dir
then after second user input it sorts the dir with size bigger than the size given
0
Comment
Question by:acorp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1388784
hi acorp,
a commandline-program like a dosbox?
meikl



0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1388785
? a bat can do it ? be more specific !

@echo off
if %1 =="" goto Usage
dir %1
pause
dir %1 /os
goto exit
:usage
echo Give a dir
:exit

meikl
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 600 total points
ID: 1388786
hi acorp,

now a simple sample, please explain more about
>sorts the dir with size bigger than the size given
?sort by name or by size or just exclude as this sample

unit getdir_u;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Filectrl;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Edit1: TEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

var TheDir : String;

procedure GetFiles(PathFileName : string; Size : Integer);
var
  srec : TSearchRec;
  Path, FileName : String;
begin
 Form1.Memo1.Lines.Clear;
 Path := ExtractFilePath(PathFileName);
 FileName := ExtractFileName(PathFileName);
 if findfirst(PathFileName,faanyfile,srec) = 0 then
   repeat
     If Not(srec.attr and fadirectory > 0) then
       if srec.size > size then
         Form1.Memo1.Lines.add(Srec.Name + '//'+ inttostr(Srec.size));
   Until findnext(srec) <> 0;
 FindClose(SRec);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  If ParamCount > 0 then
  begin
    TheDir := ParamStr(1);
    if not DirectoryExists(TheDir) then
    begin
      Showmessage('Invalid Directory');
      halt;
    end
    else
    begin
      If TheDir[Length(TheDir)] <> '\' then TheDir := TheDir + '\';
      GetFiles(TheDir+'*.*',0);
    end;
  end
  else
  begin
    Showmessage('Parameter missing');
    halt;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  GetFiles(TheDir+'*.*',strtoint(edit1.text));
end;

end.

meikl

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 1388787
oops, forgotten, the whole whole size
replace with this

var
  TheDir : String;
  CollectedSize : Integer;

procedure GetFiles(PathFileName : string; Size : Integer);
var
  srec : TSearchRec;
  Path, FileName : String;
begin
 Form1.Memo1.Lines.Clear;
 CollectedSize := 0;
 Path := ExtractFilePath(PathFileName);
 FileName := ExtractFileName(PathFileName);
 if findfirst(PathFileName,faanyfile,srec) = 0 then
   repeat
     If Not(srec.attr and fadirectory > 0) then
       if srec.size > size then
       begin
         Form1.Memo1.Lines.add(Srec.Name + '//'+ inttostr(Srec.size));
         CollectedSize := CollectedSize + Srec.Size;
       end;
   Until findnext(srec) <> 0;
 FindClose(SRec);
 Form1.Edit1.text := InttoStr(CollectedSize);
end;

meikl
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1388788
Hi Meikl,

I think you're missing a very important part of the question:

"Its for my exam"

The EE guidelines clearly state that EE forums may not be used for solutions to homework and related problems. Both the asker and the answerer of such questions risk being thrown off EE.

Cheers,

Raymond.

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1388789
oops, overlooked this, thanks raymond.
acorp, let delete this q.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question