Jump to content

A Small Parse Error HElp!!


daxguy

Recommended Posts

I was trying to access my files in a folder i have to further manipulate them but i am havin the following error

 

Warning: opendir(C: mpp\htdocs\j) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\re_name.php on line 3

Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\re_name.php on line 5

filename : ( and the loop keeps on rolling down)

 

my code is

 

$dir = "C:\xampp\htdocs\j";
$file_open = opendir($dir);

while(($file = readdir($file_open)) !== FALSE)
{
echo "filename : ".$file."<br />";
}

closedir($file_open);

 

i do not understand wer am i creating the mistake!!

Link to comment
Share on other sites

well another stupid issue.. well i have written the code to rename sum .mp3 files from the folder.. the folder is accessed i can read the files.. now i wanted to rename them.. like the songs are were are you - aliance.mp3

i am trying to explode the file name with symbol '-' as i just want the title of the song not the artist..

 

$dir = "C:\\xampp\\htdocs\\music";
$file_open = opendir($dir);
$count = 1;
while(($file = readdir($file_open)) !== FALSE)
{
$title = $file;
$symbol = '-';
$pos = strpos($title, $symbol);
if($pos == true)
{
	$refined_title = explode($file, '-');
	$success = rename($dir."\\".$file, $dir."\\".$refined_title[0] .".mp3");
	if($success)
	{
		echo "Your files have been renamed!!";
	}
	else
	{
		echo "Could Not Rename the files!!";
	}
}
}
closedir($file_open);

 

The result i get is the songs get renamed but just with .mp3 nd get over written cuz all the songs get the same name.. the problem is that i cannot get the name of the file after exploding it.. the refined_title[0] is empty.. the explode aint working on this..

any oder solutions guys?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.