Count files in Spicyfm script

Started on the old forum in June 2011 · view the original in the archive · old links redirect here

3 replies · 945 views · started 15 years ago · 1 min read

4 participants
yorme Newbie · 3 posts #1

Good day, please, i would like to show the number of files in each directory on Spicyfm script which i downloaded but i don't know how to do that. please help me. An example is:

Pictures (number of files)
Application (number of files)

Your response will be so much appreciated. Thanks very much
opticalpigion Lead · 593 posts #2
$dir_path = "/path/to/directory/";
$count = count(glob($dir_path . "*"));

if($count >= 1){
 echo $count;

} else {
 echo 0;
}
arnage Lead · 811 posts #4

Where you want it to appear. 🙂

Just a little modified:

function count_files($dir_path = '', $what = '') {
	$count = count(glob($dir_path.'/*.'.$what.''));
	return echo 'There is '.($count > 1 
			? '<b>'.$count.'</b> files' : ($count == 1 
			? '<b>one</b> file' : '<b>no files</b>')).' in '.dirname($dir_path).'<br/>'.PHP_EOL;
}
//
count_files('downloads/images', 'jpg');
count_files('downloads/images', 'jpg|jpeg');
count_files('downloads/videos', '3gp');
count_files('downloads/videos', '3gp|mp4');
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close