Archive for September, 2009

FOR Command Batch File

FOR %file_name IN (criteria) DO command
The %file_name is a variable that will contain the name of the current file being processed. These follow usual command line batch programming variable naming conventions; they start with a % (if used in a batch file), and can be any alpha value. They can not be the numbers 0 [...]

What Batch File Programming Can Be Used For

Batch file programming is a very useful way to automate small, repetitive, tasks. The Windows Command Line Programming tutorial is a good starting place to read about the basics of batch file programming, for those who are new to creating batch files.
It is also a good idea to have a debugger handy, such as the [...]

Attach Date/Time Stamp To A File - Can Be Used For Automated Backups

Here is an interesting one. I found a way to take the %date% environment variable, and turn it into a valid string for a filename - without any extra programs or scripts.
For the longest time I used a little utility I created to do this. The problem with that is the utility needs to be [...]

Dated Directories Backup Using Batch File

In the example below, we first set 3 variables: drive, folder, and backupcmd. The “drive” variable defines the root directory of our backups. The “folder” takes the 2 digit day value from the current date (US date format, taking 2 digits from the date command output, starting at the 7th character), which we will use [...]

Backup Using Batch File - Set Current Date as a Name of The Backup

Sometimes it is useful to create folders with the date incorporated in the folder name. Here is how to set the variable folder to the current date (assuming US system date format):
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%
%backupcmd% “…source dir…” “%drive%\%folder%\…destination dir…”
It is also possible to use the current time in the folder name. The following example with incorporate both [...]

Backing up Directories and networked PCs using Batch File

You can backup other directories by simply creating more alike lines:
%backupcmd% “…source dir…” “%drive%\…destination dir…”
For example, if you’d like to backup “C:\Program Files\Microsoft Office” to our destination “G:\Backup\MS Office” (and retain the directory structure) you’d need to add the following line to the batch file:
%backupcmd% “C:\Program Files\Microsoft Office” “%drive%\MS Office”
Here is another example, backing up [...]

Backup “My Documents”, Favorites, Outlook Express email/address book, (all for the current user) and the Windows Registry Using Batch File

Sometimes it is useful or even necessary to simply copy existing directories to another hard disk or network drive rather than using more complicated backup methods. Multiple directories can be backed up comparatively easy with a simple click by creating and running a batch file. That file can be executed manually from your desktop, can [...]

Batch file that downloads files from FTP server on Windows Scheduler

Batch file that can be run from windows scheduler to download two files from my server via ftp. I have username password address location of the file and filename.
V@echo off
> %0.ftp echo o mysite.com
>> %0.ftp echo username
>> %0.ftp echo password
>> %0.ftp echo bin
>> %0.ftp echo cd mydir
>> %0.ftp echo prompt
>> %0.ftp echo mget filename.ext
>> [...]