Solved

programming a batch file

Posted on 1998-07-25
3
149 Views
Last Modified: 2010-05-03
I'm still an avid user of Dos batch files to run my regular routines, like pkzipping all my essential files on a  daily basis.  Since I have several folders containing files all over my hard drive, I already have a batch file in place, with a shortcut to my desktop making it even easier to execute the command.

With win98, there is a schedule feature which can run this file for me every few hours automatically.

However, I do not know how to use the IF, Not, Exist etc commands and was hoping someone could help me.

What would I need to have in the batch file, if I wanted my system to automatically copy e.g c:\backup\docs.zip to my Iomega zip drive (d:\) ONLY if the name of the zip disk in the drive at that time is called BACKUP-DISK (volume label).  You see if I have another disk in the drive, I dont want several copies of the doc.zip on several disks, as this will only confuse things later.

Furthermore, is it possible to get the batchfile to create a second doc1.zip on the same disk, if the last backup of doc.zip was not less than 7 days old?

Many thanks, and long live DOS!

Regards
Dan.


0
Comment
Question by:ey143
  • 2
3 Comments
 
LVL 39

Expert Comment

by:abel
ID: 1466657
Start programming in perl for dos!

from a .BAT:
-It's possible check if a file already exists
-It's not possible to check for a volumelabel
-it's not possible to check for attributes, timestamps and all that...

if you REALLY like dos (and don't want to use perl), try looking up some batch-enhancers. There are thousands of them on the internet.

Regards, Abel

BTW: 50 points means "easy". What's your q.?
0
 

Author Comment

by:ey143
ID: 1466658
> vol d: | find /i"backup-Disk"
> if errorlevel 1 goto baddisk
>   copy code goes here
> goto cont
> :baddisk
>   echo error message
> :cont


Someone gave me the above commands to type into my batch file.
I have not tried it as yet, but is there a reason why it would not work and check the volume label that you say it wont do?

Do you know where I can hold of perl or batch enhancers?

Many thanks.

Dan.

PS Why is there no accept, reject screen here?  I cant give any points
0
 
LVL 39

Accepted Solution

by:
abel earned 0 total points
ID: 1466659
Sorry, I forgot that you could use the errorlevel (it's been so long ago that I used DOS).
Search for "batch and enhancer" at www.filepile.com. There are a lot of other sites that have these kinds of files, but a lot of "oldies" are at FilePile.
Perl is mostly used with the Web (in stead of the slow MS ASP). It has beautiful string-manipulation routines. You can use it like "Dir *.* >dir.txt" and then extract dir.txt. It's a very powerful programming language and it can be run from DOS. It's totally free and you can find it at www.perl.com. You'll also find the source as well as different builds. Download one compatible with win32 (can be run on DOS 7) or find the 16 bits DOS build (must be there also).

You didn't find the accept/reject screen because I didn't "answer" this question. This one is an Answer, the previous one was a Comment.

Regards, Abel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now