$version) { if(askMulti("Rollup ".$curr_version." is available (you have ".$version.")", array("Cancel","Download")) == 1) { exec("open https://www.profiteroles.org/git/profiteroles/Rollup"); echo "QUITAPP\n"; } else { die; } } else { echo "\nALERT:Up-to-date|".$version." is the latest version.\n"; die; } } // API key check if (!@$p['key'] && (strpos($p['pt'],"%PLACE") != false || strpos($p['vt'],"%PLACE"))) { echo "Warning: \"%PLACE\" will not work without an API key!\n"; } // Build list of valid dropped files foreach ($argv as $target) { if (is_dir($target)) { $it = new RecursiveDirectoryIterator($target); foreach(new RecursiveIteratorIterator($it) as $file) { if (in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)), $p['allowed'])) { $files[] = $file->getpathname(); } } } elseif (in_array(strtolower(pathinfo($target,PATHINFO_EXTENSION)), $p['allowed'])) { $files[] = $target; } } if (!@$files) { echo "\nALERT:No supported files|Supported filetypes: ".implode(", ",$p['allowed'])."\n"; die; } else { sort($files); } if (count($files) > $p['limit']) { if (!ask("Really process ".count($files)." files?")) { die; } } // Process files $i = 0; foreach ($files as $file) { unset($parts, $ext, $mparts, $z, $e); $parts = pathinfo($file); $ext = strtolower($parts['extension']); $z['%FILE'] = $parts['filename']; $z['%EXT'] = $parts['extension']; if ($p['debug_verify_names']) { $p['maxlength'] = 999; $z['%FILE'] = substr($parts['filename'],-8,8); echo "[VERIFY]"; } else { echo $parts['basename']; } if (strlen($parts['basename']) > $p['maxlength']) { echo "-> SKIP\n"; } else { $raw = eval("return ".shell_exec($p['etbin']." -php ".escapeshellarg($file))); if (is_array($raw[0])) { $e = $raw[0]; } else { echo "Exiftool error\n"; die; } $z['%DTO'] = formatDateTime($e); $z['%DUR'] = formatDuration($e); $z['%SW'] = formatSoftware($e,$p); $z['%MODEL'] = formatModel($e); $z['%PLACE'] = formatPlace($e,$p); if (in_array($ext,$p['pfiletypes'])) { $newname = str_replace(array_keys($z),array_values($z),$p['pt']); } elseif (in_array($ext,$p['vfiletypes'])) { $newname = str_replace(array_keys($z),array_values($z),$p['vt']); } $figureoutabetterwaytodothis_a = array("____","___","__"); $figureoutabetterwaytodothis_b = array("_","_","_"); $newname = str_replace($figureoutabetterwaytodothis_a,$figureoutabetterwaytodothis_b,$newname); if (!@$newname) { echo " -> ERROR\n"; } else { echo " -> ".$newname."\n"; if ($p['debug_verify_names']) { if ($parts['basename'] != $newname) { echo "FAIL"; echo "\nALERT:Filename changed|".$parts['basename']." VS ".$newname;; } else { echo "pass"; } } else { if (!@$p['dry_run']) { rename($file,$parts['dirname']."/".$newname); } else { echo "\nDisable dry run to rename files!"; } } } echo updateProgress($i,count($files)); $i++; } } ?>