![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: Event Logging and Move File OVERWRITE "Robert Jacobs" <robertjacobsit@xxxxxx> wrote Quote: > Below is the script - any advice? 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 Specs![]() |
| | #2 (permalink) |
| | 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 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 Specs![]() |
![]() |
| 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 | |||