Solved

how to zip specific files

Posted on 2008-09-30
2
436 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
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now