Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: Event Logging and Move File OVERWRITE

Reply
 
Old 07-24-2009   #1 (permalink)
Larry Serflaten


 
 

Re: Event Logging and Move File OVERWRITE


"Robert Jacobs" <robertjacobsit@xxxxxx> wrote
Quote:

> Below is the script - any advice?
You have a lot of duplicate code. Lines that all look alike, except for
a variable or two. Could you not wrap one section up in a Sub and
call it once for each file type?

Also each section begins with:

If objFSO.folderExists(sSrcPath) And objFSO.FolderExists

When sSrcPath doesn't change anywhere in your code. You really
only need to test it once, do you not? What are the chances of it
being destroyed while your script is running?

Also, to handle your overwrite problem, Kill the matched files before
you move them. Do it from a sub you write to Kill the file if it exists,
or do nothing otherwise. Then you can call it ahead of your Move for
every file.

But I wonder if you need to iterate over evey file? Wouldn't the FSO
MoveFile method do what you want? Something like:

FSO.MoveFile "D:\MCL3\LINK\Data\*.CRD", "S:\Credits\"
FSO.MoveFile "D:\MCL3\LINK\Data\*.LAB", "S:\Labels\"
... Etc...

???
LFS





My System SpecsSystem Spec
Old 07-24-2009   #2 (permalink)
Robert Jacobs


 
 

Re: Event Logging and Move File OVERWRITE

On Jul 24, 11:58*am, "Larry Serflaten" <serfla...@xxxxxx>
wrote:
Quote:

> "Robert Jacobs" <robertjacob...@xxxxxx> wrote
>
Quote:

> > Below is the script - any advice?
>
> You have a lot of duplicate code. *Lines that all look alike, except for
> a variable or two. *Could you not wrap one section up in a Sub and
> call it once for each file type?
>
> Also each section begins with:
>
> If objFSO.folderExists(sSrcPath) And objFSO.FolderExists
>
> When sSrcPath doesn't change anywhere in your code. *You really
> only need to test it once, do you not? *What are the chances of it
> being destroyed while your script is running?
>
> Also, to handle your overwrite problem, Kill the matched files before
> you move them. *Do it from a sub you write to Kill the file if it exists,
> or do nothing otherwise. *Then you can call it ahead of your Move for
> every file.
>
> But I wonder if you need to iterate over evey file? *Wouldn't the FSO
> MoveFile method do what you want? *Something like:
>
> FSO.MoveFile "D:\MCL3\LINK\Data\*.CRD", "S:\Credits\"
> FSO.MoveFile "D:\MCL3\LINK\Data\*.LAB", "S:\Labels\"
> .. Etc...
>
> ???
> LFS
If I do FSO.MoveFile "D:\MCL3\LINK\Data\*.LAB" , "S:\Labels\", it will
attempt to move all .LAB files, but if it encounters an error, it will
not continue on moving the rest of the files after the encountered
error. I am calling the same sub over and over again, but I'm
changing the differnet destination paths and file extensions to be
moved each time the sub is called. I know the chances aren't great of
the folder being destroyed while in the middle of running the script,
but NO MATTER WHAT, this script cannot crash during the day, so I am
putting in any error checking/handling I possibly can to ensure that
if an error occurs, the script continues to run, and on top of that,
continues to move files files added to the source folder even if a
file in that source folder is encountering errors. It seems silly,
but this script will run continuously, all day, every day, and will
need to be able to run into countless problems, log them, and continue
to work.

Could you elaborate on how I would "Kill the matched files before you
move them."?
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Overwrite Text File in Loop VB Script
How to overwrite a file in Vista Windows folder Vista security
Event Viewer, Logging Vista General
PowerShell Event Logging PowerShell
File overwrite Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46