Re: Debugging Help Please! :) File renaming...
- From: Dakota Interactive <onebucktraffic@xxxxxxxxx>
- Date: Sat, 13 Sep 2008 10:08:53 -0700 (PDT)
The array consists of instances of any file with extension PST on a
given computer. So if it finds more than one file with the same name -
for example, outlook.pst - then it is supposed to rename them
including the file creation date as part of the filename.
On Sep 13, 11:59 am, knothead <knoth...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
When you say files with the same please explain more. Are you meaning
users1000 and users1001? Are you counting the first eight characters?
Me me you need more logic in last Else clause.
Else
"onebucktraf...@xxxxxxxxx" wrote:
Thanks for reading this.
This code segment is part of a larger script that moves PST files so
that they are accessible to users anywhere in the network. The rest of
the script works but this is making me nuts. This is supposed to
determine if two or more files have the same name, and if so, rename
them to include the file dat or timestamp as well. It doesn't work.
Can some offer some guidance?
DI
'[Rename Code] - Renames PST files with timestamp
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='y:\mailbox'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
strDate = Left(objFile.FileName & "_" & objFile.CreationDate, 30)
strNewName = objFile.Drive & objFile.Path & _
strDate & "." & "pst"
strNameCheck = Replace(strNewName, "\", "\\")
i = 1
Do While True
Set colFiles = objWMIService.ExecQuery _
("Select * from Cim_Datafile Where Name = '" &
strNameCheck & "'")
If colFiles.Count = 0 Then
errResult = objFile.Rename(strNewName)
Exit Do
Else
i = i + 1
strNewName = objFile.Drive & objFile.Path & _
strDate & "_" & i & "." & "pst"
strNameCheck = Replace(strNewName, "\", "\\")
End If
Loop
Next
'[End Rename Code]
.
- References:
- Debugging Help Please! :) File renaming...
- From: onebucktraffic
- RE: Debugging Help Please! :) File renaming...
- From: knothead
- Debugging Help Please! :) File renaming...
- Prev by Date: RE: Debugging Help Please! :) File renaming...
- Next by Date: Re: creating complete file path
- Previous by thread: RE: Debugging Help Please! :) File renaming...
- Next by thread: Re: Debugging Help Please! :) File renaming...
- Index(es):
Relevant Pages
|