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 - Scripting: Zipping files and checking Network Share

Reply
 
Old 11-27-2008   #1 (permalink)
Chris


 
 

Scripting: Zipping files and checking Network Share

Community,

First off, have done some VB.Net programming - but am in No way an expert. I
probably forgot 80% of it since i do not use it often.

I am trying to write a script (fun so far!) that performs a few specific
tasks. I'm looking for some pointers, reference sites that can help me with
the following items:
Task 1
Copy source files to destination only if they do not exsist on the
destination drive.
(completed)

Task 2
create a zip file in MMM-YYYY.zip, check date of file (prob. created date)
and move the file to the archive. However, I do not want to copy files
created the same day the script is running. So, if Nov-2008.zip was created
- all files for the month of November get moved into the archive. This script
will run several times a day.

Task 3
The script is going to be running on the destination machine. Using network
shares, but do not want to map a drive. I want the script to check for
connectivity to the source drive. Once I have this - I think I can figure
out how to have it loop until a successful connection is made - and send out
e-mail alerts if unable to establish a connection after x many tries or some
sort of counter value.


Here is what I have thus far:

' Purpose:
' Check Source and Destination. If source has a file that destination does
not, copy source to destination. One-way Sync
' In Source: Create a zip container for the current month/year (MMM-YYYY)
and move files made in that time frame
' to that zip container - do not include files generated on the same day
the script is running.
' Require Error checking (first for network connectivity, than file
copying) Notify by e-mail on all errors and continue loop until network
' connection is made.
'
' Duration: Script to run Hourly, Monday through Friday
'
Dim objFilesys,Folder,objMessage,srcFolder,dstFolder,srcFile,objShell

srcFolder ="\\wrkstation-ip\Greefa_Data\"
dstFolder ="\\server-ip\common\Intake and Processing
Division\Pre-Sort\Greefa_Data\"

Set objFilesys = CreateObject("Scripting.FileSystemObject")
Set objShell = Wscript.CreateObject("Wscript.Shell")

CopySource()

WScript.Quit

'Copies the Source to Destination, minor error checking
Sub CopySource()
For Each srcFile in objFilesys.GetFolder(srcFolder).Files
If Not objFilesys.FileExists(dstFolder &
objFilesys.GetFilename(srcFile)) Then
objFilesys.GetFile(srcFile).Copy dstFolder &
objFilesys.GetFilename(srcFile),False
Else
Msgbox(srcFile & " File Exists")
End If
Next
End Sub

Sub MonthlyZip()
objShell.Exec(...)
' Thinking of using 7zip if I cannot figure out how to use native Win2k3 zip
End Sub


Any suggestions?

My System SpecsSystem Spec
Old 11-27-2008   #2 (permalink)
Tim Williams


 
 

Re: Scripting: Zipping files and checking Network Share

Zipping:
http://www.rondebruin.nl/windowsxpzip.htm

Tim

"Chris" <Chris@xxxxxx> wrote in message
news:618687AA-5EF6-4E7D-BDFD-1089131CD70A@xxxxxx
Quote:

> Community,
>
> First off, have done some VB.Net programming - but am in No way an expert.
> I
> probably forgot 80% of it since i do not use it often.
>
> I am trying to write a script (fun so far!) that performs a few specific
> tasks. I'm looking for some pointers, reference sites that can help me
> with
> the following items:
> Task 1
> Copy source files to destination only if they do not exsist on the
> destination drive.
> (completed)
>
> Task 2
> create a zip file in MMM-YYYY.zip, check date of file (prob. created date)
> and move the file to the archive. However, I do not want to copy files
> created the same day the script is running. So, if Nov-2008.zip was
> created
> - all files for the month of November get moved into the archive. This
> script
> will run several times a day.
>
> Task 3
> The script is going to be running on the destination machine. Using
> network
> shares, but do not want to map a drive. I want the script to check for
> connectivity to the source drive. Once I have this - I think I can figure
> out how to have it loop until a successful connection is made - and send
> out
> e-mail alerts if unable to establish a connection after x many tries or
> some
> sort of counter value.
>
>
> Here is what I have thus far:
>
> ' Purpose:
> ' Check Source and Destination. If source has a file that destination
> does
> not, copy source to destination. One-way Sync
> ' In Source: Create a zip container for the current month/year (MMM-YYYY)
> and move files made in that time frame
> ' to that zip container - do not include files generated on the same day
> the script is running.
> ' Require Error checking (first for network connectivity, than file
> copying) Notify by e-mail on all errors and continue loop until network
> ' connection is made.
> '
> ' Duration: Script to run Hourly, Monday through Friday
> '
> Dim objFilesys,Folder,objMessage,srcFolder,dstFolder,srcFile,objShell
>
> srcFolder ="\\wrkstation-ip\Greefa_Data\"
> dstFolder ="\\server-ip\common\Intake and Processing
> Division\Pre-Sort\Greefa_Data\"
>
> Set objFilesys = CreateObject("Scripting.FileSystemObject")
> Set objShell = Wscript.CreateObject("Wscript.Shell")
>
> CopySource()
>
> WScript.Quit
>
> 'Copies the Source to Destination, minor error checking
> Sub CopySource()
> For Each srcFile in objFilesys.GetFolder(srcFolder).Files
> If Not objFilesys.FileExists(dstFolder &
> objFilesys.GetFilename(srcFile)) Then
> objFilesys.GetFile(srcFile).Copy dstFolder &
> objFilesys.GetFilename(srcFile),False
> Else
> Msgbox(srcFile & " File Exists")
> End If
> Next
> End Sub
>
> Sub MonthlyZip()
> objShell.Exec(...)
> ' Thinking of using 7zip if I cannot figure out how to use native Win2k3
> zip
> End Sub
>
>
> Any suggestions?

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Access Denied on Network Share Files Vista networking & sharing
Vista + Copying files over network share = 100% CPU? Vista General
Saving files from Vista Machine to xp network share Vista networking & sharing
Error opening files on a network share. Vista file management
Accessing files on Vista network share breaks network Vista networking & sharing


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