I need do a directory listing of files that has a file name format like this.

 Quote:

FooLog-0-YYYY-MM-DD.csv


I need to take this list of files and rename in this format.

 Quote:

servername_PROD_YYYYMMDD_HHMMSS_fooLOG_0000.csv


The "0" after foolog is the part that is causing me some problems. In the renamed format the series of "0's" is any number up to thousands but I need to pad 0's if it isn't 4 digits.


Also, when I run this against a directory, it will only process one file while deleting the rest of the directory.

Here is what I have so far. Any help would be appreciated:

 Code:
$path="c:\admin\foo"
$archive="c:\admin\archive"
$date=@DATE
$time=@TIME
$modtime=Join(Split($time,":"),"")
$moddate=Join(Split($date,"/"),"")



$Dir = dirscan($path,1)
For Each $file in $dir
  If InStr($file,"-")
   Move $path+"\"+$file $archive+"\"+@wksta+"_prod_"+$moddate+"_"+$modtime+"_foolog_0000.csv"
  EndIf
Next
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain