What's wrong with this script?

design

#1

[code]<?php

print “hello\n”;

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

require_once(’…/getid3/getid3/getid3.php’);

$dir = ‘tmp’;
$result = scandir ($dir);
arsort($result);
foreach ($result as $file)
{
rename ("$file", “sermons/$file”) or die (“Could not move file”);
}
?>
[/code]


#2

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


#3

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?


#4

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’;
$d=opendir($dir);
while (false !== ($file = readdir($d))) {
$files[]=$file;
}
sort ($files);
foreach ($files as $file) {

Silk

My website