Amit Dhamu

Writes Code

Recursive Directory Scanning

Use this to recursively iterate through a directory (i.e. the files and folders within).

$iterator = new RecursiveDirectoryIterator("C:\Users\Amit\Favorites");

foreach(new RecursiveIteratorIterator($iterator) as $file) {
    $size = $file->getSize();
    echo "$file - $size kb<br/>";
}


Example Output

C:\Users\Amit\Favorites\Microsoft Websites\IE Add-on site.url - 133 kb
C:\Users\Amit\Favorites\Microsoft Websites\IE site on Microsoft.com.url - 133 kb
C:\Users\Amit\Favorites\Microsoft Websites\Microsoft At Home.url - 133 kb
C:\Users\Amit\Favorites\Microsoft Websites\Microsoft At Work.url - 133 kb
C:\Users\Amit\Favorites\Microsoft Websites\Microsoft Store.url - 134 kb
C:\Users\Amit\Favorites\MSN Websites\MSN Autos.url - 133 kb
C:\Users\Amit\Favorites\MSN Websites\MSN Entertainment.url - 133 kb
C:\Users\Amit\Favorites\MSN Websites\MSN Money.url - 133 kb
C:\Users\Amit\Favorites\MSN Websites\MSN Sports.url - 133 kb
C:\Users\Amit\Favorites\MSN Websites\MSN.url - 133 kb
C:\Users\Amit\Favorites\MSN Websites\MSNBC News.url - 133 kb
C:\Users\Amit\Favorites\Windows Live\Get Windows Live.url - 133 kb
C:\Users\Amit\Favorites\Windows Live\Windows Live Gallery.url - 133 kb
C:\Users\Amit\Favorites\Windows Live\Windows Live Mail.url - 133 kb
C:\Users\Amit\Favorites\Windows Live\Windows Live Spaces.url - 133 kb


directory / scan / recursive / iterators / php

← Get Mouse Coordinates Social Bookmark Share Function →