News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Help please!

Started by James Bone, September 02, 2004, 03:25:52 AM

Previous topic - Next topic

James Bone

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!

Christian Land

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).' ---&gt; '.htmlspecialchars($dest.$newname).'<br />';
}
}
}

echo '</font>';

$oDir->close();

?>

James Bone

Thats exactly it!! Thanks alot!

PM me your email and i will send you a GMAIL invite.

James

Advertisement: