?
Solved

how to zip specific files

Posted on 2008-09-30
2
Medium Priority
?
447 Views
Last Modified: 2012-05-05
hi everyone,

i have this script which BKsupport kindly helped me i want this script to zip the files in the source folder first and then copy the zip file to destination folder.

is that possible?

Set fso = CreateObject("Scripting.FileSystemObject")  
 
' Set the Folder Locations
sfolder = "\\lts-srv3\public\datadump1\" ' Folder copying from
dfolder = "\\lts-srv1\users\pgoodway\ian data\" 'Folder copying to
zFile = "\\lts-srv1\users\pgoodway\ian data\ZippedFile.zip"
 
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
 
For each folderIdx In files
	
    if folderIdx.DateCreated >= date then
	zip sfolder & folderIdx.name, zFile
    end if
Next
 
 
Function Zip( myFileSpec, myZip )
 
    Dim objZIP
    On Error Resume Next
    Err.Clear
    Set objZIP = CreateObject( "XStandard.Zip" )
    objZIP.Pack myFileSpec, myZip, , , 9
    Zip = Err.Number
    Err.Clear
    Set objZIP = Nothing
    On Error Goto 0
 
End Function 
 
Msgbox "Finished"  
 
Open in New Window Select All

Open in new window

0
Comment
Question by:ammartahir1978
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 2000 total points
ID: 22606416
To copy the zip file you should be able to add this below line 17:


If fso.FileExists(zFile) Then
    fso.CopyFile zFile, dfolder
End If

Open in new window

0
 

Author Comment

by:ammartahir1978
ID: 22711087
but that script zip everything instead for some specific filei want how can i achive that??
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question