Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

qbasic zip log files program help

qbasic zip log files program help

qbasic zip log files program help

I have a server that generates log files from Internet Information Server for website reporting purposes. These log files are saved in d:\logfiles\w3svc*. There are currently 103 w3svc folders with logfiles. The files saved in this folder are saved in ex year/month format (ex0503 - The year 2005 in March). These reports are generated monthly. The log files get pretty big so I have to zip up the log files monthly to save disk space. So, what I am trying to accomplish is to write a program that automatically zippes up the exmonthdate files within the w3svc folders. Then copies the zip files to another server on the network. Next deletes the zipped and the .log files from the source. Here is what I have:
QBASIC Program that automatically zippes the files called test2.
FOR i = 1 to 200
PRINT "Zipping d:\logfiles\w3svc" + LTRIM$(STR$(i))
CHDIR d:\logfiles\w3svc" + LTRIM$(STR$(i))
SHELL "PKZIP d:\logfiles\w3svc" + LTRIM$(STR$(i)) + "\ex0503.zip" d:\logfiles\w3svc" + LTRIM$(STR$(i)) + "\ex0503.log"

The program works but once it get to the last w3svc it just displays "Path Not Found" when its done. I think I need to set some sort of loop b/c the number of w3svc folder is always changing.

Then once that is done I run the copyit.bat which contains this code:
@echo off
rem COPYIT.BAT transfers all files in all subdirectories of
rem the source drive or directory (%1) to the destination rem drive or directory (%2)

xcopy d:\logfiles\*.zip p:\logfiles\test /s /e

if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit

echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit

echo You pressed CTRL+C to end the copy operation.
goto exit


This program works very nice.

Then once that is done I run the delete.bat which contains the code:
del d:\logfiles\*.zip
del d:\logfiles\*ex0503*

What I should do is combine all these functions into one program. Then run a scheduled task every month on the server. I don't know how to fix my loop issue in the qbasic program and call the batch files within QBASIC. Can someone help?

RE: qbasic zip log files program help

the path not found may be the result of the file not being found.

You could open the file in binary mode, check the lof, close the file then if > 0 then continue with the zip. otherwise it should go to the next number and check for that file.

you could call the qbasic program in the bat file (as well as the delete bat file.

Or get powerbasic for windows and zlib and do it all within
the program.

RE: qbasic zip log files program help

There is a QBasic library called ADVBAS that includes the command
That allows you to check if a file exists. You could include that in your loop to get out when there were no more files.

You can download it from here as ADVBAS.ZIP

RE: qbasic zip log files program help

You're asking:


how to fix my loop issue in the qbasic program and call the batch files within QBASIC.

This is a two-fold question:

Part one: looping issue
What you are asking is/has been covered in several other posts. From adding a variable--so you can adjust the 200 limit to Self-counting submodulized code.  I'd suggest you use the Search capabilities on this site to help you find what you are looking for.

Part two: calling a batch file
You already have the basics for the appropriate code in your loop...suggest you use the QB Help files and read up on the SHELL command again.  Apparently, you didn't quite understand this command, but yet you know how to utilize it for an outside program. Again I'd suggest you re-read your help files.

Otherwise, if you have specific code that is giving you a serious problem, then please post again.


--> It's a bird!  It's a plane!  No, it's an OS update patch! Ahh!! <--

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close