Looking for Small Program

Started by Shoeb Omar, August 31, 2004, 11:42:42 PM

Previous topic - Next topic

Shoeb Omar

Hey guys,

I was wondering if any of you kknew of a program to grab all files in a directory and all it's subdirectories.

e.g. if I have directory structure as follows:

Big Folder
- File 1
- File 2
= Subfolder 1
- File in Subfolder 1

etc.

I'd want a printable list like;

/file1
/file 2
/subfolder 1/file in subfolder 1

any ideas?

- Shoeb

[Unknown]

dir /s /b > listing.txt

-[Unknown]

Parham


<?

print <<<EOF
<HTML>

<HEAD>
<TITLE></TITLE>

</HEAD>
<BODY>

<PRE>

EOF;

$total_files = 0;
$total_directories = 0;

listdir('c:/directory/directory/'); //directory here, end it with a slash please

function listdir($current_path) {

global $total_files,$total_directories;

$dir_handle = opendir($current_path);
while ($current_file = readdir($dir_handle)) {

  if ($current_file == '.' or $current_file == '..') { continue; }

  if (is_dir("$current_path$current_file" )) {
    print "<B>$current_path$current_file</B>\n";
    $total_directories++;
    listdir("$current_path$current_file/");
  } else {
    print "$current_path$current_file\n";
    $total_files++;
  }

}
closedir($dir_handle);

}

print <<<EOF

TOTAL DIRECTORIES = $total_directories
TOTAL FILES = $total_files
</PRE>

</BODY>
</HTML>
EOF;

?>

Parham

sorry for the messy code shoeb :/

[Unknown]

Quote from: Parham on September 01, 2004, 01:28:33 AM

<?

print <<<EOF
<HTML>

<HEAD>
<TITLE></TITLE>

</HEAD>
<BODY>

<PRE>

EOF;

$total_files = 0;
$total_directories = 0;

listdir('c:/directory/directory/'); //directory here, end it with a slash please

function listdir($current_path) {

global $total_files,$total_directories;

$dir_handle = opendir($current_path);
while ($current_file = readdir($dir_handle)) {

  if ($current_file == '.' or $current_file == '..') { continue; }

  if (is_dir("$current_path$current_file" )) {
    print "<B>$current_path$current_file</B>\n";
    $total_directories++;
    listdir("$current_path$current_file/");
  } else {
    print "$current_path$current_file\n";
    $total_files++;
  }

}
closedir($dir_handle);

}

print <<<EOF

TOTAL DIRECTORIES = $total_directories
TOTAL FILES = $total_files
</PRE>

</BODY>
</HTML>
EOF;

?>


<php

passthru('dir c:\\directory\\directory /s /b');

?>


:P

-[Unknown]

Amacythe

* Amacythe looks at the topic
Looking for Small Program
* Amacythe looks at Parham and [Unknown]'s replies
hmmm

;)

[Unknown]

Quote from: [Unknown] on September 01, 2004, 01:31:36 AM
<php

passthru('dir c:\\directory\\directory /s /b');

?>


:P

-[Unknown]

Actually...

<php

header('Content-Type: text/plain');

$dir = 'c:\\directory\\directory';

exec('dir ' . $dir . ' /s /b', $array);
foreach ($array as $entry)
   echo strtr(trim($dir), array($dir => '', '\\' => '/')), "\n";

?>


Assuming you're on windows.

-[Unknown]

Tony Reid

#7
Actually I like the tree command in w2k & XP not sure if its in windows 95/98/me?

tree /f
Tony Reid

Parham

you're all haters LOL
he posted in the PHP board :P

Advertisement: