Jump to content
sapnawat

Php code to get metadata from folder having mp3 files

Recommended Posts

Posted (edited)

Inside one folder i have around 200 folder's and each folder's having 150 mp3 files.

I want to get metadata of each mp3 file's 

below is the code which i have tried but getting below error.

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(C:\Users\Desktop\Rajesh song,C:\Users\Desktop\Rajesh song): The system cannot find the path specified. (code: 3)' in C:\xampp\htdocs\getID3-master\rajupal.php:4 Stack trace: #0 C:\xampp\htdocs\getID3-master\rajupal.php(4): RecursiveDirectoryIterator->__construct('C:\\Users\\Deskto...') #1 {main} thrown in C:\xampp\htdocs\getID3-master\rajupal.php on line 4

<?php
include("getid3/getid3.php"); 
$directory = 'C:\Users\Desktop\Rajesh song';
$filename = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
while($filename->valid()) {
if (!$filename->isDot()) {
$getID3 = new getID3;
$file = $getID3->analyze($filename);
//print_r($file);
$playtime_seconds = $file['playtime_seconds'];
$dumpa=gmdate("H:i:s", $playtime_seconds);
$filesize = $file['filesize'];
$filepath = $file['filepath'];
$filename = $file['filename'];
$filename1 = $file['fileformat'];
echo "<table class='table table-striped'>";
echo "<tr>";
echo "<th>File Path</th>";
echo "<th>Name</th>";
echo "<th>Size(kb)</th>";
echo "<th>Duration</th>";      
echo "<th>File Type</th>";
echo "</tr>";
echo "<tr>";
echo "<td> ".$filepath."</td>";
echo "<td> ".$filename."</td>";
echo "<td> ".$filesize."</td>";
echo "<td> ".$dumpa."</td>";      
echo "<td> ".$filename1."</td>";      
echo "</tr>";
echo "</table>";
}
$filename->next();
}
?>

 

Edited by sapnawat

Share this post


Link to post
Share on other sites

The message is clear. The path is wrong. You probably want:

$directory = "C:\Users\%username%\Desktop\Rajesh song";

 

Share this post


Link to post
Share on other sites

Hi gw1500se,

Thanks for the reply.

I have change path to $directory = "C:\Users\%username%\Desktop\Rajesh song"; but still getting error.

 

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(C:\Users\%username%\Desktop\Rajesh song,C:\Users\%username%\Desktop\Rajesh song): The system cannot find the path specified. (code: 3)' in C:\xampp\htdocs\getID3-master\rajupal.php:4 Stack trace: #0 C:\xampp\htdocs\getID3-master\rajupal.php(4): RecursiveDirectoryIterator->__construct('C:\\Users\\%usern...') #1 {main} thrown in C:\xampp\htdocs\getID3-master\rajupal.php on line 4

Share this post


Link to post
Share on other sites

I don't know where that directory is, you do. I only know the path you had originally did not make sense so I made a suggestion. You have to provide the correct path.

Share this post


Link to post
Share on other sites
Posted (edited)

sure!

The correct path of file is C:\Users\r.shishodia\Desktop\Rajesh song.

Rajesh song is folder name having two mp3 files.

Edited by sapnawat

Share this post


Link to post
Share on other sites

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.