What is wrong with this picture sorting PHP script?

Nvidiaorati

New member
This script is supposed to scan my "F:/Pictures/Photography" directory for photos, including those inside of subfolders. Analyze the date/time they were tooken, then create a new folder named New in "F:/Pictures/Photography/new" in the new folder all the photos that the script as scanned in the photography directory will be put here in to sub folders, starting from the year 2006, any pictures taken before this year will just be renamed. It will then put photos from the year of 2006 to 2010, in to sub folders named the appropriate year, inside of the year folder, will be another folder named 1 to 12, 1 being january and 12 being december. The photos will also go through a sorting method, which will rename every photo it scans in the Photography directory, from their previous name to the prefix IMG_ and the suffix of 00000 and incrementing to one, in knowledge of the time the photo was tooken.

Example:

F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/3/IMG…
F:/Pictures/Photography/new/2010/4/IMG…
F:/Pictures/Photography/new/2010/4/IMG…
F:/Pictures/Photography/new/2010/4/IMG…
F:/Pictures/Photography/new/2010/4/IMG…

The file numbering system resets for each new month
F:/Pictures/Photography/new/2010/3/IMG…

<?php
$keyb = 0;
$dir = 'F:\Pictures\Photography';
for ( $da = 2006; $da <= 2010; $da++ ) {
for ( $month = 1; $month <= 12; $month++ ) {
unset($files);
$d = scandir($dir . '\' . $da . '\' . $month);
foreach($d as $dd ) {
if ( $dd != '.' && $dd != '..' ) {
$var = exif_read_data($dir . '\' . $da . '\' . $month . '\' . $dd);
$files[$dd] = mktime(substr($var['DateTimeOriginal'],1…
}
}
asort($files);
foreach($files as $key => $val) {
rename($dir . '\' . $da . '\' . $month . '\' . $key,$dir . '\new\IMG_' . $keyb . '.JPG');
$keyb++;
}
}
}
?>

Error log: http://pastebin.com/ERTvTHHG
Running Xampp
 
Back
Top