Re: Debugging Help Please! :) File renaming...
- From: "Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 13 Sep 2008 15:58:42 -0600
"Pegasus (MVP)" <I.can@xxxxxxxxxx> wrote in message
news:uD6AeOeFJHA.616@xxxxxxxxxxxxxxxxxxxxxxx
"Dakota Interactive" <onebucktraffic@xxxxxxxxx> wrote in message
news:03293d0a-8a5a-455d-9bf2-d660bf94db81@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
My apologies... here is the entire thing, fully commented.
<snip>
After I've had a bit of a look at your code I was left somewhat confused.
Here is why:
- You declare objFSO three times. Why?
- You have two subroutines called ScanSubFolders. Why?
- You have these two lines of code:
If fso.DriveExists("Y:") Then WshNetwork.RemoveNetworkDrive
"Y:",True,True
wshShell.Run "subst Y: /D"
What is the point of removing a non-existing substitution?
- You have these three lines of code:
For Each File In colFiles
Set objFile = objFSO.GetFile(strFolder & "\" & File.Name)
Next
What is the point of repeatedly creating an object without doing
anything with it?
- The lines
strDate = Left(objFile.FileName & "_" & objFile.CreationDate, 30)
strNewName = objFile.Drive & objFile.Path & strDate & "." & "pst"
will set strNewName to a string that includes the date in universal time
format,
which is unsuitable for a file name.
Analysing and debugging some 250 lines of someone else's code can take a
lot of time unless the issue is straightforward. I suggest you describe in
functional terms what you're trying to do. I suspect that someone will
then suggest a simple solution to your problem.
Exactly. Also, it is even more difficult to determine the cause of a
particular problem in someone's code when there are so many problems with
it.
Here is an earlier post:
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?
Your definition of the task is a bit suspect. If I were writing such a
script I would never even bother to figure out if more than two files had
the same name. Rather, for each file processed in turn, I would determine if
a file of the same name existed in the target folder, and then copy it under
a new name if necessary.
But, given that some files will be given new names, why not simply do that
to all of the files placed there?
/Al
.
- References:
- Debugging Help Please! :) File renaming...
- From: onebucktraffic
- Re: Debugging Help Please! :) File renaming...
- From: Pegasus \(MVP\)
- Re: Debugging Help Please! :) File renaming...
- From: Dakota Interactive
- Re: Debugging Help Please! :) File renaming...
- From: Pegasus \(MVP\)
- Re: Debugging Help Please! :) File renaming...
- From: Dakota Interactive
- Re: Debugging Help Please! :) File renaming...
- From: Pegasus \(MVP\)
- Debugging Help Please! :) File renaming...
- Prev by Date: Re: String to int conversion
- 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
|