Solved

how to zip specific files

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
quick dos batch to update files. 3 63
Copy from network drive to local computer using batch 7 46
batch file problem 5 67
Autorun Remote Desktop - USB Stick 6 26
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

792 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