ey143
asked on
programming a batch file
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.
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.
ASKER
> 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
> 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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.?