Qbasic, Quickbasic/batch file wanted

Advertisement


Question

Batch file attempt.JPG
I'm trying to make a batch file to back up new documents to a flash drive so if the hard drive goes out I have my documents.

All I should have to do is click on the icon on my desktop (Windows XP) and the file should back up the needed documents to the flash drive. After the first back up it should only copy new or changed files.

I keep getting an 'invalid path' error. I've tried lots of different paths:
For example - - I:\ for the 'from' path and also different versions of the path for the 'to' version, but nothing seems to work.

Am I doing something which is basically impossible? I don't see why it shouldn't be possible though...

See the attached files for the Explorer view of her computer and the result I get when I try to run the batch file.

The 'I' drive is the flash drive and her files are on the 'C' drive.

Thanks,
Jim

HERE IS MY BATCH FILE:
*******************************************

@echo off

:: variables

set drive=I:\Phyllis

set backupcmd=xcopy /s /c /d /e /h /i /r /y

 

echo ### Backing up My Documents...

%backupcmd% "C:\Documents and Settings\Phyllis\My Documents\"

 

echo Backup Complete!

@pause

*******************************************

Note, I have a similar batch file on my home computer which works fine. Here is the one on my home computer:

@echo off
:: variables
set drive=D:\Tempbackups
set backupcmd=xcopy /s /c /d /e /h /i /r /y

echo ### Backing up My Documents...
%backupcmd% "L:\My Documents\Autocad--DRW" "%drive%\Autocad--DRW"
%backupcmd% "L:\My Documents\Jim" "%drive%\Jim"
%backupcmd% "L:\My Documents\Kalu" "%drive%\Kalu"

echo Backup Complete!
@pause


Answer
Hi, Jim,

First, I want to note that this is the QBasic section, and not a DOS-Batch section, so technically, there is no guarantee that I'd know anything about this.  Luckily, I do know batch, but next time, make sure this gets to the right section.

The problem is you're not telling xcopy where to put your files...

%backupcmd% "C:\Documents and Settings\Phyllis\My Documents\"

This doesn't say where you're copying files to, just where the original files are, to fix that:

%backupcmd% "C:\Documents and Settings\Phyllis\My Documents\" "%drive%\Phyllis"

Take care,
-Alex

Qbasic, Quickbasic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Alex Barry

Expertise

I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, QB64, c/c++, python, lua, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience

I have been programming in *Basic dialects since 2000, as mentioned in my expertise. After a year of QBasic, I learned C and C++, and dabbled a little in ASM (I don't program in ASM - I literally just played around to see how things work). When QB64 and FreeBASIC were released, I played with those languages. At the time, FreeBASIC offered more functionality and I sided with that language for a while. During that time, while I was learning new languages, that I would see what scripting languages are available, where I took up python and lua. I started to notice a staleness to QB64's development (which I kept tabs on from time to time), and am now trying to be active in it's community and maybe in it's development in the future. Currently, I am only active on the QB64.net forums, but I appear on occasion on FreeBASIC.net's forums as well.

Education/Credentials
Highschool - 2007

©2012 About.com, a part of The New York Times Company. All rights reserved.