Link to home
Start Free TrialLog in
Avatar of ammartahir1978
ammartahir1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

how to zip specific files

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

ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ammartahir1978

ASKER

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