# Solved: Compression vbscript file help



## usmc-ratman (Aug 6, 2004)

(WinXP sp3)

Need assistance with vb script that will run 7za compression program on files in a source directory, and name the 7za archive based on the date/time of the archive. Example:
source files: c:\BU\Database\*.*
destination 7za archive: c:\BU\110408_1400_Databases.7za

I know the 7za command line if I were doing it manually would be:
7za.exe a "C:\BU\110408_1400_Databases.7z" "c:\BU\Database\*"

But I do not know how to make it a into .vbs file

Any assistance would be greatly appreciated.

Thanks,
JR


----------



## -Fabez- (Jul 28, 2008)

Why dont you use batch if you know how to do it ?


----------



## usmc-ratman (Aug 6, 2004)

Fabez, I would do it in bat files also if I knew how to get the date/time format to be inserted at the beginning of the file name. I tried several times, but it would not work properly, and I could not get the date/time format correct (mmddyy_hhmm_filename). If bat files would be better than vbs, that will do, but when bat files run, the cmd window appears, with vbs, there are no windows popping up when it executes.
Im pretty sure that the vbscript version on the machine is v5.
Any suggestions, I'm still trying to learn.

Thank you,
JR


----------



## -Fabez- (Jul 28, 2008)

You could use Python, it allows you to execute commands as if they were typed at the command prompt and it can get the time and date.


----------



## usmc-ratman (Aug 6, 2004)

Using Python, is that something that can be executed using the windows task scheduler? or is that a program that I would need to be in the Python GUI to execute each time?


----------



## -Fabez- (Jul 28, 2008)

Python programs can be made into stand alone .Exe's using Py2Exe so you will not need the Python runtime installed to use the program.


----------



## usmc-ratman (Aug 6, 2004)

Ok - will check into that.... In the mean time, I have been tweaking my original bat file, and finally got something that "works", but I cant figure out the format on the date/time. This is what I have right now

```
@echo off
setlocal
set timestamp=%DATE:/=%%TIME:~0,2%%TIME:~3,2%
7za.exe a -mx1 -r "C:\tmp\%timestamp%_Databases" "c:\data files\databases\*.mdb"
```
this gives me an output of 
110508 956_Databases.7z​which is almost what I want. I just need the time to be in 24hr format. I just dont understand the
~0,2 and ~3,2​designators on the date/time. Where can I find an explanation on this format, or do you know what format designators I would put on that 'timestamp' line to get the time format that I am looking for?

JR


----------



## usmc-ratman (Aug 6, 2004)

Fabez,
Thank you for pointing me towards Python - I will be checking it out as I have time. I have worked out the structure for the date/time stamp by trial and error.
For others that may be looking for a similar routine, this is what I finally ended up with:


> *
> @echo off
> setlocal
> set mm=%Date:~0,2%
> ...


Thanks,
JR
Semper Fi


----------



## -Fabez- (Jul 28, 2008)

Glad it worked for you


----------

