Programming

Simple Programming - Part 1

Programming isn't all about complicated, expensive, programming languages and having to compile code into executables - sometimes programming can be simple and in this set of simple articles I hope to introduce you to "simple yet effective" programming.

To begin with we'll look at batch files. Batch files are simple text files that contain instructions for the PC to carry out. Some people don't think of batch file programming as "real" programming but I'm not that fussy or that arrogant and think that if you are writing a file that makes the PC do something, you're programming!

OK, all you need for this is a text editor - Windows Notepad will do just fine!

Now you can begin to write the code.

I find that one of the main things that people want to do is move files - backups are important (as anyone who's done the Caring for your PC class will know). Writing batch files that copy files is easy.

1 - Fire up a text editor, like Notepad.

2 - Choose the file you want to move and choose where you want it moved to.  What I've done is create two folders and used these.  Mine are on separate drives but yours don't have to be.

3 - Now start writing code. Say I had a file called "money.mny" (Microsoft Money file) in a folder called "files" on C drive and I wanted to copy those to a folder called "backup" on D drive I would type in the following:

copy c:\files\money.mny d:\backup\money.mny

4 - Save the file but remember to give it the ".bat" file extension.

5 - Run the file (some antivirus packages might ask you to confirm the running of the file.  These files are 100% safe - just as long as you remember where you are copying files to!).

6 - If you wanted to rename the backed up file, you could do this:

copy c:\files\money.mny d:\backup\money_backup.mny

7 - If you wanted, say to copy all the files in the "files" folder you'd write:

copy c:\files\*.* d:\backup\*.*

This will copy the files. If you wanted to give the files a specific additional file extension so that you can tell backups from real files (for example .bak), try this:

copy c:\files\*.* d:\backup\*.*.bak

Enough for now - more to follow!  I hope this has whetted your appetite for more programming!

Go to Next Part >>

Adrian Kingsley-Hughes
Last updated: May 3rd 2006
Print This Page   |   Email me when this page changes    |  Search This Site



Crucial.com System Scanner does the work for you!



links.inc"); ?>

Contact Us