DOS/Windows

Posts about using DOS and Windows.

Syncing Files Using The Windows Command Line

10th November 2010 - 5 minutes read time

To sync files using the Windows command line you will need to use the xcopy command. The default action of this program is to copy a file or directory from one place to another, but you can give it flags to tell it to sync the files. There are a few flags available (use xcopy /? to see them all) but you will probably only want to use the following:

Set An IP Address From The Command Prompt In Windows

19th November 2008 - 4 minutes read time

Rather than use the old connection properties dialog in Windows you can open up a command prompt and use the netsh to set up all sorts of network specific settings. The most useful part of this is that you can create a bat file that will allow you to quickly change your local IP address very quickly.

To see a list of the network connections available you can use the following command.

netsh interface show interface

This runs the netsh program, in the interface context, and shows the interfaces available. There are lots of other contexts to chose from, just type netsh and then ? to see a list of commands. If you type in netsh and hit enter key you will see the prompt change to netsh meaning that you are in that program mode. Just type exit or bye to exit.

You can also ask for information about individual interfaces by using the name parameter.

Loop Through All Files In A Directory With DOS Batch

16th September 2008 - 4 minutes read time

DOS Batch is the Windows equivalent of shell scripting and can be used to perform all sorts of different actions. Anything that you type into a DOS prompt on a Windows machine can be used in a bat file to quickly do something that you would otherwise have to repeat many times over. To create a bat file just make a file and give it the extension "bat". If you run a DOS prompt and navigate to the directory that the bat file exists in you can type the name of the file to get it to do certain actions. If you called your file "action.bat" you can run it by typing "action" or "action.bat". Starting with a simple example, if you want to print the contents of a file to screen then you need the type command, followed by the file.


type file.txt

However, this puts a lot of rubbish on the screen. If you wanted to create a backup of that file then you would write the following.