Avatar of SmartestVEGA
SmartestVEGA
 asked on

VB script to zip files

Need a VB script which will zip the files (.dat) into 2 gb chunks

Eg:

In
C:\folder1\

There are following in file in date format . I have included the space there.

A21112009.dat  (1.7 gb)
b21112009.dat  (0.5 gb)
c22112009.dat  (0.2 gb)
d23112009.dat  (1.3 gb)
e24112009.dat  (1.5 gb)
f25112009.dat  (0.4 gb)

I want a zip file of 2 gb (max)  ( in order of dates first)

Like

21to22Nov2009.zip
23to23Nov2009.zip
24to25Nov2009.zip
VB ScriptScripting LanguagesShell Scripting

Avatar of undefined
Last Comment
SmartestVEGA

8/22/2022 - Mon
Lukasz Chmielewski

what zipping app you're using ?
SmartestVEGA

ASKER
usually i do this manually

by right clicking the .dat file and sent to > Compressed zip folder

Lukasz Chmielewski

better would be to download 7zip (freeware)
http://www.7-zip.org/

and run the command line arguments with 7zip app
Your help has saved me hundreds of hours of internet surfing.
fblack61
SmartestVEGA

ASKER
I cannot install any softwares or download anything in my system

Because i dont have any privliage, and its hard to get it ..

is there any other way?

Lukasz Chmielewski

you can use command line tool "compact.exe" but id does not support splitting to volumes,
there is a possibility for use a stand alone zipping tool, I assume you have proper right to run an exe file ?
SmartestVEGA

ASKER
but i cannot download in anything from internet there!!

Will be there any exe in system32 or any windows folder to zip ?

how the right click compress option works ..?

which exe it is calling ??

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Lukasz Chmielewski

it calls compact.exe, try it from the command line, but like i wrote, it does not support splitting into volumes
Lukasz Chmielewski

to be precise: c:\windows\system32\compact.exe
SmartestVEGA

ASKER
OK..u mean to say that ... it will be code to split my files into 2 GB chunks ...right?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SmartestVEGA

ASKER
sorry ..it will not be ..coded!!
SmartestVEGA

ASKER
i have done as u said

please see the code below:

But it doesnot transformed to .zip instead i got the attached file !


dim ShellObj
set ShellObj = WScript.CreateObject("WScript.Shell")
str= """C:\WINDOWS\system32\compact.exe"" ""C:\jaison.zip"" C:\jaison.txt"
ShellObj.run str,,true

Open in new window

AllApps
SmartestVEGA

ASKER
sorry its not allapps file


i didnt get any output at all

is there anything wrong with the code?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Lukasz Chmielewski

this compress tool is a non zip compression, it is xp compressing folder. windows xp does not have command line tool for zip compression, you should use a third party tool
SmartestVEGA

ASKER
But i can see compact.exe in my system32 folder!
Lukasz Chmielewski

yes, it is, thou it is not the same as sending to compressed file (rclick in xp)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SmartestVEGA

ASKER
so any other solutions ??
Lukasz Chmielewski

you need to get 7zip (this would be the fastest and simplest way) and since you cannot download anything i'd try to download 7zip into other machine, install it and copy the folder containing program to your machine. then you would have possibility to compress files into zips. in fact ANY third party stanalone tool for zipping would do ok
Lukasz Chmielewski

gzip tool would do ok also
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SmartestVEGA

ASKER
i installed winrar

and used below code

same problem still

no resoponse after code execution
dim ShellObj
set ShellObj = WScript.CreateObject("WScript.Shell")
str= """C:\Program Files\WinRAR\rar.exe"" ""C:\Jaison.rar"" C:\Jaison.txt"
ShellObj.run str,,true

Open in new window

Lukasz Chmielewski

use
dim ShellObj
set ShellObj = WScript.CreateObject("WScript.Shell")
str= "C:\Program Files\WinRAR\rar.exe a C:\Jaison.rar C:\Jaison.txt"
ShellObj.run str,,true

Open in new window

SmartestVEGA

ASKER
See the error now !
ZipError.JPG
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Lukasz Chmielewski

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SmartestVEGA

ASKER
Its worked for time being :-)
Lukasz Chmielewski

also if you need to split to volumes use

dim ShellObj
set ShellObj = WScript.CreateObject("WScript.Shell")
str= "C:\WinRAR\rar.exe a -v100 C:\Jaison.rar C:\Jaison.txt"
ShellObj.run str,,true

-v100 is 100kb, so if you need 2 gb you have to write -v2000000 (or sth like that) :)
SmartestVEGA

ASKER
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.