Author Topic: [Delphi] Foldurs  (Read 7928 times)

0 Members and 1 Guest are viewing this topic.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
[Delphi] Foldurs
« on: September 08, 2011, 01:04:32 pm »
Oh fuck am I bored during programming classes... have to code such useless stuff to keep me awake and amused :D

This program will create 100 folders on your desktop with random name of 10 chars.

You can easily change numbers yourself, I commented where what could be changed...

Compiled Exe: http://newage.ql.lt/projects/delphi/Foldurs/Foldurs.exe
Project: http://newage.ql.lt/projects/delphi/Foldurs/Foldurs.zip

Code for an oversight, and I think you can compile that with FreePascal compiler:
Code: [Select]
(*
  Author: Kulverstukas
  Written on: 2011-09-08
  http://newage.ql.lt/
  ------
  Program to create lots
  of folders on your Desktop.
*)

program Foldurs;
{$APPTYPE CONSOLE}
{$R *.dres}

uses
  SysUtils;
const DefaultFolders = 100; // If nothing is given in an argument, this value is used
var Desktop : String;
    FolderCount, Folders : integer;
//==========================================
(* Generate a random name in given length of given chars *)
function RandomName : String;
const abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqestuvwxyz';
      Name = 10;  // this number states how long will the folder name be
var Count : integer;
    NameStr : String;
begin
 for Count := 1 to Name do
  begin
    NameStr := NameStr + abc[System.Random(51)];
  end;
  Result := Trim(NameStr);
  NameStr := '';
end;
//==========================================
(* Strip crap from the string and leave only numbers *)
function PickNumbers(Line : String) : Integer;
var Ch : String;
    ChCount : integer;
begin
 for ChCount := 1 to length(Line) do
  begin
    if (Line[ChCount] in ['0'..'9']) then
    Ch := Ch + Line[ChCount];
  end;
 if (Ch = '') then Result := DefaultFolders
 else Result := StrToInt(Ch);
end;
//==========================================
begin
 if (ParamCount > 0) then
  Folders := PickNumbers(ParamStr(1))
 else Folders := DefaultFolders;
 Desktop := SysUtils.GetEnvironmentVariable('userprofile');
 Desktop := Desktop + '\Desktop';
 for FolderCount := 1 to Folders do
  begin
    SysUtils.CreateDir(Desktop+'\'+RandomName);
  end;
end.
« Last Edit: September 10, 2011, 08:47:49 pm by Kulverstukas »

Offline xzid

  • Knight
  • **
  • Posts: 329
  • Cookies: 41
    • View Profile
Re: [Delphi] Foldurs
« Reply #1 on: September 08, 2011, 07:12:08 pm »
normally I wouldn't run something like this, but I'm about to install linux on this laptop and might as well trash windows before I do so. Will also run much more malicious code.

Also I thought you were learning java? Your teacher wouldn't be happy about this.  >:(

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Delphi] Foldurs
« Reply #2 on: September 08, 2011, 07:39:49 pm »
bla bla bla  >:(

Yeah I am learning it but classes now are more centered about general rules of programming, like algorithms and I already know that stuff and in a day on my own I learn as much as they teach us in a week :P so I am way ahead of my class...
« Last Edit: September 08, 2011, 07:40:17 pm by Kulverstukas »

Offline xzid

  • Knight
  • **
  • Posts: 329
  • Cookies: 41
    • View Profile
Re: [Delphi] Foldurs
« Reply #3 on: September 08, 2011, 09:49:28 pm »
pfft your exe quit after 5, wasn't too thrilling

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Delphi] Foldurs
« Reply #4 on: September 08, 2011, 10:43:31 pm »
pfft your exe quit after 5, wasn't too thrilling
Oh... probably the old exe - I set it to 5 for testing. Compile it yourself with new values :D

Offline xzid

  • Knight
  • **
  • Posts: 329
  • Cookies: 41
    • View Profile
Re: [Delphi] Foldurs
« Reply #5 on: September 08, 2011, 10:59:48 pm »
I figured that, but too late though . computer no long runs windows... It doesn't run linux either.. My netinstall failed, so no more fucking around downloading 4.5GB of DVD! They coulda told me they couldn't find their files before formatting... Assholes. Anywayz for the the moment I get:

"Missing operating system"

I don't think your program will run on this computer.

xor

  • Guest
Re: [Delphi] Foldurs
« Reply #6 on: September 10, 2011, 07:44:17 am »
Kulver, you really need to stop hard coding your program values. :P

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Delphi] Foldurs
« Reply #7 on: September 10, 2011, 08:50:15 pm »
Kulver, you really need to stop hard coding your program values. :P

OKAY! fine... I fixed it. Now it accepts a number to make folders. If none is given then program is run with default values - 100. You can combine letters/symbols and numbers, program will strip that shit leaving only numbers.

Foldurs.exe 9999999