Jump to content

File Counter


PandaPHP

Recommended Posts

I have 30,000 files to upload onto my webspace but there is a file limit of 1000 per directory so I must use several directories.

 

$dir = "/home/freefla/public_html/";
$folderid = 1;
$filecount = count(glob($dir . $folderid .  "/.swf")) ;

 

Firstly whats wrong with my code above as it always returns 0 or 1 files regardless?

 

Secondly how do I put this into a for loop to automatically increase the folder ID when the previous folder is full (for 5 files for testing purposes). I have tried to do this myself but failed :(

Link to comment
https://forums.phpfreaks.com/topic/205503-file-counter/
Share on other sites

<?php
$dir = "/home/freefla/public_html/domains/free-arcade-games.org.uk/wp-content/games/";
$fid = 1;

do {
if (file_exists($dir . $fid)){
	$counter = count(glob($dir . $fid . "/*.*"));
	echo "folder " . $fid . " has " . $counter . " files <br />";
		if ($counter >= 6) {
			$fid++;
		}
} else {
	echo "folder " . $fid . " does not exist <br />";
	echo "creating folder " . $fid . "<br />";
	mkdir($dir . $fid, 0755);
}
} while ($counter >= 6);

?>

 

Fixed, how does this look?

Link to comment
https://forums.phpfreaks.com/topic/205503-file-counter/#findComment-1075391
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.