Solved

how to zip specific files

Posted on 2008-09-30
2
443 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

733 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