DOS commands

To merge file1, file2, file3 into file4:

type file1 file2 file3 >> file4

To merge file1, file2, file3 into file4:

copy file1+file2+file3 file4

To send email from a command prompt:

telnet 25 (a valid smtp domain)
helo (the actual smtp domain you are sending from)
mail (a valid email address at the current smtp domain)
rcpt (desired recepient)
“Enter the message here…
. (end message with a single “”.”” on a line by itself)
Press “”Enter”” to send the message”

QTo copy a file + date/time stamp it:

ren D:\folder\file.log file-%date:~4,2%-%date:~7,2%-%date:~10,4%@%time:~0,2%%time:~3,2%%time:~6,2%h%.log
ren D:\folder\file.log file-%date:~4,2%-%date:~7,2%-%date:~10,4%@%time:~1,1%%time:~3,2%%time:~6,2%h%.log

Rem rename command is done twice (2) to allow for 1 or 2 digit hour,
Rem If before 10am (1digit) hour, rename starting at location (0) for (2) chars,
Rem will error out, as location (0) will have a space and space is invalid character for file name,
Rem so second rename will be used.
Rem if equal 10am or later (2 digit hour) then first rename will work and second will not
Rem as file2.log will not be found (it is already renamed)

To date stamp a file:

date /t > d:\folder\file.txt
IF EXIST D:\folder\file.txt. (

type file1.txt file2.txt file3.txt >> D:\folder\file4.csv.)

General commands:

doskey /history = Displays the history of all commands used in current session
F1 = retypes the previous command one character at a time
F2 = brings up a dialog and asks “Enter the char to copy up to:”
F3 = retypes the last command in full
F4 = brings up a dialog and asks “Enter char to delete up to:”
F5 = same as for F3
F6 = Print EOF character (Ctrl+Z)
F7 = brings up a dialog of all the recent command history
F8 = brings up each of the most recent commands, one at a time
F9 = brings up a dialog and asks “Enter command number:”


@echo off
echo —————- %date% %time% —————- >> “”%userprofile%\cmdHistory.txt””
doskey /history >> “”%userprofile%\cmdHistory.txt””


@echo off
if %1. == . (
type “”%userprofile%\cmdHistory.txt”” 2> nul
echo —————- %date% %time% —————-
doskey /history
) else (
if /i %1. == /edit. (
start “”Revising History…”” “”%userprofile%\cmdHistory.txt””
) else (
echo ——————————————- Previous Windows
type “”%userprofile%\cmdHistory.txt”” 2> nul | findstr /i “”%*””
echo ———————————————— This Window
doskey /history | findstr /i “”%*””