Hello all you coding peeps! I am looking for a program (PHP or PERL) to go into a specified directory and change files that are named like this:
_0325153723_001.tif
and change their filename to:
Syyyymmddhhnnss.tif
so in this example
S20040325153723.tif
and move it to another directory.
Can anyone help?
If you want an incentive theirs a Gmail invite on offer!
Something like this?
<?php
$source = '/tmp/'; // Source-Path
$dest = '/tmp/test/'; // Destination-Path
$pattern = '/_(\d+?)_(\d+?).tif/i';
//
$oDir = dir($source);
echo '<font face="courier">';
while (false !== ($entry = $oDir->read()))
{
if (is_file($source.$entry))
{
if (preg_match($pattern,$entry,$matches))
{
$newname = 'S2004'.$matches[1].'.tif';
rename($source.$entry, $dest.$newname);
echo htmlspecialchars($source.$entry).' ---> '.htmlspecialchars($dest.$newname).'<br />';
}
}
}
echo '</font>';
$oDir->close();
?>
Thats exactly it!! Thanks alot!
PM me your email and i will send you a GMAIL invite.
James