From: Marc M on
Hello,

I need a script that can rename file extensions for files in a
specific folder if they are older than 36 hours.

Any help with this is greatly appreciated!

-Marc
From: Pegasus [MVP] on


"Marc M" <marc.manfredi(a)gmail.com> said this in news item
news:db14ca4e-d70e-443c-956d-3e6fb7542431(a)k5g2000pra.googlegroups.com...
> Hello,
>
> I need a script that can rename file extensions for files in a
> specific folder if they are older than 36 hours.
>
> Any help with this is greatly appreciated!
>
> -Marc

Have a look at the DateDiff function. It lets you determine timestamp
differences in seconds, minutes, hours etc. etc. You will find full details
in the downloadable helpfile script56.chm.



From: Marc M on
On Feb 15, 4:43 pm, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
> "Marc M" <marc.manfr...(a)gmail.com> said this in news itemnews:db14ca4e-d70e-443c-956d-3e6fb7542431(a)k5g2000pra.googlegroups.com...
>
> > Hello,
>
> > I need a script that can rename file extensions for files in a
> > specific folder if they are older than 36 hours.
>
> > Any help with this is greatly appreciated!
>
> > -Marc
>
> Have a look at the DateDiff function. It lets you determine timestamp
> differences in seconds, minutes, hours etc. etc. You will find full details
> in the downloadable helpfile script56.chm.

Pegasus, thanks for the reply. I looked up the DateDiff function and
it seems to be a way to compared between two fixed days/dates. I will
create a scheduled task to run everyday and the script needs to look
at the files in a particular folder and rename then if they are older
than 36 hours. I didn't see a way to do this with the DateDiff
function. Did I miss something? Thanks for your assistance.

-Marc
From: Marc M on
On Feb 16, 11:28 am, Marc M <marc.manfr...(a)gmail.com> wrote:
> On Feb 15, 4:43 pm, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>
> > "Marc M" <marc.manfr...(a)gmail.com> said this in news itemnews:db14ca4e-d70e-443c-956d-3e6fb7542431(a)k5g2000pra.googlegroups.com...
>
> > > Hello,
>
> > > I need a script that can rename file extensions for files in a
> > > specific folder if they are older than 36 hours.
>
> > > Any help with this is greatly appreciated!
>
> > > -Marc
>
> > Have a look at the DateDiff function. It lets you determine timestamp
> > differences in seconds, minutes, hours etc. etc. You will find full details
> > in the downloadable helpfile script56.chm.
>
> Pegasus, thanks for the reply.  I looked up the DateDiff function and
> it seems to be a way to compared between two fixed days/dates.  I will
> create a scheduled task to run everyday and the script needs to look
> at the files in a particular folder and rename then if they are older
> than 36 hours.  I didn't see a way to do this with the DateDiff
> function.  Did I miss something?  Thanks for your assistance.
>
> -Marc

I have this so far-

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root
\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='c:\stdf_tmp'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
If objFile.Extension = "stdf_tmp" Then
strNewName = objFile.Drive & objFile.Path & _
objFile.FileName & "." & "stdf"
errResult = objFile.Rename(strNewName)
Wscript.Echo errResult
End If
Next
From: Pegasus [MVP] on


"Marc M" <marc.manfredi(a)gmail.com> said this in news item
news:df8138e7-bb30-4c73-afe6-003d6969bde7(a)g19g2000yqe.googlegroups.com...
> On Feb 16, 9:34 pm, Marc M <marc.manfr...(a)gmail.com> wrote:
>
> The behavior that I'm trying to avoid is for the script to only rename
> files with a stdf_tmp extension to stdf extension and not touch any
> other files in the folder, basically ignore all other files. It seems
> that the script will modify all files in the folder, not just the ones
> with the stdf_tmp extension and it will rename files every time it
> runs.

You need to add an "if then" statement that tests your file name, e.g. like
so:

if {the 8 right-most characters of the file name are stdf_tmp} then
if the file is older than 36 hours
rename it
end if
end if