What's wrong with this script?


print “hello\n”;

ini_set (‘display errors’, 1);
error_reporting (E_ALL);


$dir = ‘tmp’;
$result = scandir ($dir);
foreach ($result as $file)
rename ("$file", “sermons/$file”) or die (“Could not move file”);

Well for starters there is no base directory being specified. For example,[code]$dir = ‘tmp’;

*** should be ***

$dir = realpath(’/home/username/tmp’);[/code] :cool: [color=#6600CC]Atropos[/color] | openvein.org

I have a script which scans a direction in a similar fashion, and it is given a relative path just as this one and that script works just fine. What benefit is gained from specifying a base directory?

I am thinking the problem maybe because you are lacking the ./ in front of your directory.

You could do something like the following as an alternative.

$dir = ‘./tmp’;
while (false !== ($file = readdir($d))) {
sort ($files);
foreach ($files as $file) {


My website