Programming
Simple Programming - Part 2
In the previous article in this series on simple programming I looked at how you can use simple programming, in the form of batch files, to copy files from one location on your PC to another. In this article we'll take that concept further and look at moving files.
Note: Remember that when moving files it's easy for them to get lost - make sure you keep track of where you are moving them to and practice on unimportant files first.
First, a quick refresher on what batch files are:
1 - Batch files are plain text files. That is, they are not compiled or coded in any special way.
2 - The only tool you need to create batch files is a simple text editor, which can be as simple and no-nonsense as Windows Notepad or fully-functional as UltraEdit (http://www.ultraedit.com)
3 - Batch files can carry out simple tasks - forget about graphics and interface here!
4 - Remember that batch files need to be saved with the .bat file extension.
OK, with that out of the way, let's look at moving files with batch file programming.
Remember the syntax we used for copying a single file:
copy c:\files\money.mny d:\backup\money.mny
Moving files is just as easy, just change copy to move:
move c:\files\money.mny d:\backup\money.mny
If I had a whole stack of .mny files there in one folder I could copy them all with this single line of code:
move c:\files\*.mny d:\backup\
So far, all our batch files have contained a single line of commands. This is powerful but multiple lines of code allow for far more power. The following batch commands would move .mny files and .txt files.
move c:\files\*.mny d:\backup\ move c:\files\*.txt d:\backup\
Another point to bear in mind too is that you can combine operations in batch files, so you're not limited to doing one type of operation. Here I have combined copy and move.
move c:\files\*.mny d:\backup\ copy c:\files\*.txt d:\backup\
That's enough for now - I hope that you find this interesting and see how even simple programming can make your life a lot easier. Remember that here I've chosen specific file types in specific folders, you are free to choose files and folders of your own.
Next time we'll look at some other fun stuff you can do with batch file programming!
Go to Next Part >>