how to zip specific files

Posted on 2008-09-30
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\"


Set folder = fso.GetFolder(sFolder)

Set files = folder.Files


For each folderIdx In files


    if folderIdx.DateCreated >= date then

	zip sfolder &, zFile

    end if




Function Zip( myFileSpec, myZip )


    Dim objZIP

    On Error Resume Next


    Set objZIP = CreateObject( "XStandard.Zip" )

    objZIP.Pack myFileSpec, myZip, , , 9

    Zip = Err.Number


    Set objZIP = Nothing

    On Error Goto 0


End Function 


Msgbox "Finished"  


Open in New Window Select All

Open in new window

Question by:ammartahir1978
LVL 38

Accepted Solution

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


Author Comment

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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 …
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

10 Experts available now in Live!

Get 1:1 Help Now