Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Adding files to a zip file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1976
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Adding files to a zip file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Adding files to a zip file - 2/3/2005 9:31:31 PM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
Hi,

I need to set up a job to monitor some folder and zip the content. Can anyone point me to a script to do this. I'm new to scripting and i'm not really sure where to start.

Thanks

Majid

_____________________________

M Zohreh
 
 
Post #: 1
 
 Re: Adding files to a zip file - 2/3/2005 9:55:58 PM   
  Valvola

 

Posts: 51
Score: 0
Joined: 2/3/2005
From:
Status: offline
Well, it's quite complicated...

As I know, you cant manage ZIP files with VBS

BUT

You can use ARJ (you know about it, don't you?) activated by WScript.CreateObject("WScript.Shell")

WShell can run dos commands and other funny things (ARJ is dos based)

here some info about:

Wscript.Shell:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshshell.asp

ARJ:
http://www.arjsoftware.com/

have fun!

(in reply to mzohreh)
 
 
Post #: 2
 
 Re: Adding files to a zip file - 2/4/2005 4:07:02 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
What exactly (in steps) do you want to do ?

(in reply to mzohreh)
 
 
Post #: 3
 
 Re: Adding files to a zip file - 2/5/2005 12:18:39 AM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
Thanks to token and Valvola for your replies.

As part of our sql backup process, I would like to set up a job in sql to move all weekly backups of our database to another location. This I've alreasdy achieved with vbscript. Now i would like to set up another job to zip all the files in the new location, let's say every month, into one zip file. I would like to use vbscript if possible. According to Valvola this is not possible, so i'm now looking at other alternatives.

Regards

(in reply to mzohreh)
 
 
Post #: 4
 
 Re: Adding files to a zip file - 2/5/2005 6:17:08 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
If what you want to do is simply zip all files from a certain location into ONE zip file, it can be easily done with batch file. Of course, you can do it with vbs as well. Below is the code to do it in vbs. Change the source directory and the destination zip file to whatever you desired and make sure the directory path ends with "\*" to include all files in that directory.

pkzipc is a command line tool for manipulating zip files, much like the old pkzip/pkunzip program, but with support for 32bit environment. It can be downloaded from various download sites; just do a search on google.

=================================================================
Option Explicit

Dim shell, shellExec, srcDir, destFile, temp
srcDir = "f:\1\*"
destFile = "f:\1\test.zip"

Set shell = CreateObject("WScript.Shell")
shell.Run "%COMSPEC% /c pkzipc -add " & destFile & " " & srcDir, 0

(in reply to mzohreh)
 
 
Post #: 5
 
 Re: Adding files to a zip file - 2/6/2005 7:59:23 PM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
Thanks for this token, i will try this solution.

Regards

Majid

(in reply to mzohreh)
 
 
Post #: 6
 
 Re: Adding files to a zip file - 2/6/2005 9:46:56 PM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
Hi Token,

I downloaded PKZIP and Command Line Add-On for PKZIP, but i can't zip any files. I have the code as below:

Option Explicit

Dim shell, shellExec, srcDir, destFile, temp
srcDir = "c:\test\*"
destFile = "c:\test\test.zip"

Set shell = CreateObject("WScript.Shell")
shell.Run "%COMSPEC% /c pkzipc -add " & destFile & " " & srcDir, 0
set shell = nothing

Regards

Majid

(in reply to mzohreh)
 
 
Post #: 7
 
 Re: Adding files to a zip file - 2/6/2005 11:15:07 PM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
I keep getting the follwoing error:

Executed as user: The step did not generate any output. The step failed.

M

(in reply to mzohreh)
 
 
Post #: 8
 
 Re: Adding files to a zip file - 2/7/2005 11:24:53 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
The command line added for WinZip uses different syntax than pkzipc. I don't have it installed so I can't tell you exactly what option to use. You can either research on the usage or paste the usage here so I can try to figure it out what you need.

(in reply to mzohreh)
 
 
Post #: 9
 
 Re: Adding files to a zip file - 2/7/2005 8:36:07 PM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
Hi Token,

I will use winzip command utility to achieve what i want. I have the follwoing code to do this:

dim srcDir, destFile, sDate,
sDate =day(date) & "_" & month(date) & "_" & year(date)

srcDir = "E:\MSSQL_Dev_Backups\Website\*.bak"
destFile = "E:\MSSQL_Dev_Backups\Website\"&sDate&".zip"

Set oShell = CreateObject("WScript.Shell")

iRC = oShell.Run("winzip32 -m " & destFile & " " & srcDir, 1, True)


set oShell = nothing

This works, but as i'm not a vbscript expert, i would be grateful if you could let me know what would be a good way to trap errors on the above code.

Appreciate your help.

Regards

(in reply to mzohreh)
 
 
Post #: 10
 
 Re: Adding files to a zip file - 2/8/2005 4:18:34 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
To trap the output of the command winzip32, you will need to use the exec method of the shell object rather than the run method.

eg:
Set execObject = Shell.Exec("%comspec% /c winzip32 -m " & destFile & " " & srcDir)
Do Until execObject.StdOut.AtEndOfStream
strLine = execObject.StdOut.ReadLine()
WScript.Echo strLine
Loop

You can then see the output of the command and decide on how you would catch errors with some conditional statements such as IF/END IF and others.

(in reply to mzohreh)
 
 
Post #: 11
 
 Re: Adding files to a zip file - 2/8/2005 8:39:17 PM   
  mzohreh

 

Posts: 12
Score: 0
Joined: 2/3/2005
From: United Kingdom
Status: offline
Thanks for this Token, i will try it out!

Regards

Majid

(in reply to mzohreh)
 
 
Post #: 12
 
 Re: Adding files to a zip file - 2/9/2005 12:20:42 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
No problem! :D

(in reply to mzohreh)
 
 
Post #: 13
 
 Re: Adding files to a zip file - 3/30/2005 5:02:39 AM   
  buffi

 

Posts: 87
Score: 0
Joined: 3/28/2005
From:
Status: offline
Hi All,
Can someone help me with this scrip
I tried to use it with the winzip as it was mentioned above

      

This is the the exact code i am using, but i am getting an error on the first line.
What am i doing wrong :/

Thanks
Buffi

(in reply to mzohreh)
 
 
Post #: 14
 
 Re: Adding files to a zip file - 3/30/2005 5:40:12 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Get rid of the trailing comma.

Replace:

dim srcDir, destFile, sDate,

with:

dim srcDir, destFile, sDate

(in reply to mzohreh)
 
 
Post #: 15
 
 Re: Adding files to a zip file - 3/30/2005 7:00:22 AM   
  buffi

 

Posts: 87
Score: 0
Joined: 3/28/2005
From:
Status: offline
Hehe,
Didn't see that one :)
thanks alot token,

(in reply to mzohreh)
 
 
Post #: 16
 
 Re: Adding files to a zip file - 3/30/2005 7:02:28 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
No problem =)

(in reply to mzohreh)
 
 
Post #: 17
 
 Re: Adding files to a zip file - 3/30/2005 7:15:58 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
you guys might want to take a look at 7zip. it has a very powerful command line interface.

(in reply to mzohreh)
 
 
Post #: 18
 
 Re: Adding files to a zip file - 3/30/2005 9:43:59 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Is it compatible with the "regular" zip file format ? I would prefer it to be compatible to be of any use. And its free I assume ? =)

(in reply to mzohreh)
 
 
Post #: 19
 
 Re: Adding files to a zip file - 4/2/2005 11:16:17 PM   
  buffi

 

Posts: 87
Score: 0
Joined: 3/28/2005
From:
Status: offline
Hi All,
Another small question regarding the zip files.
Does anybody have the code in vb for winzip to extruct files?
It will help alot thanks
Buffi

(in reply to mzohreh)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Adding files to a zip file Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts