Windows Command Line inherits so many good things from DOS command line... command.com is the 16bit DOS version (8 char filenames, etc.), where you use dir /x and DIR~NAME cmd.exe is the 32bit windows version (long pathnames with spaces) - some DOS native programs will have problems here
See CMD-WIN-DOS-configuration to ensure you have the optimal setup.
Start->Run->Open: cmd will open a Command Prompt window default start in your user profile home directory.
- escape key clears your current command line entry
- up arrow and down arrow allow you to see previously typed in commands (enabled by default in win32 cmd.exe) (doskey.exe was required in DOS command.com for command history, but WinXP command.com doesn't even have it)
- F7 will pop up a menu showing you the history of commands used - to use one press F9 and the history number.
- Alt + F7 will clear the cmd.exe command history cache.
- tab will autocomplete file and directory names (default is Ctrl-D and Ctrl-F but I have changed to it to TAB)
- shift tabe will try the autocomplete names in reverse order
- Ctrl-C will cancel any command that is currently running
- cls will clear the screen
- exit will close the Command Prompt window
cd c:\windows\system (or you could type cd c:\wiTAB\syTAB - much faster!)
Quotation marks at the beginning of a path allow windows to parse the spaces (you don't need the closing ") if cd c:\program files isn't recognized because of the space you can also try cd "c:\program files
dir (/b = bare, /l = all lowercase, /ad = directories, /a-d = not directories, /w=widelist)
(/og = sort directories first, /oe = sort extension, /o-d = reverse date, /x=8char format)
dir /q //Shows owners of files!
md test (mkdir= makes a directory named test) rd test (rmdir= removes a directory named test, rd /s test will recursively remove all files/dirs!)
copy con test1.txt (creates a file name test1.txt from the text typed in at console, F6 or Ctrl-Z to exit) F6
echo somerandomtexthere > text2.txt
type test1.txt (display the contents of a file) more test1.txt (display the contents of a file notepad test1.txt (open the test1.txt file in notepad)
ren test1.txt test2.txt copy test2.txt test1.txt (will create a new copy if none there, will prompt for overwrite otherwise) xcopy c:\test f:\test (will copy files and directory trees - subfolders & subfiles)
del test1.txt (same as 'erase', deletes all the files in a given directory)
output to file, overwrites
output to file, append < input from file | pipes output of first command to input of second command (not argv, cin.get) & execute two commands in order && execute second command if first command is successful || execute second command if first command is NOT successful @ Used in batch files at the beginning of a line to turn off the display, e.g. @echo off
tree /f /a (displays a tree listing of the directory & sub directories WITH files in ASCII format) tree /f /a > filetree.txt find "filetree" filetree.txt /n (shows each line where the string occurs, with the line number) fc //file compare fc filetree-today.txt filetree-yesterday.txt (path\filename1 path\filename2, defaults to current directory)
sort /o filetree.txt
FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]
/V Displays all lines NOT containing the specified string. /C Displays only the count of lines containing the string. /N Displays line numbers with the displayed lines. /I Ignores the case of characters when searching for the string. "string" Specifies the text string to find.
mkdir %date:~,2%-%date:~3,2%-%date:~6,4% REM C:\Logfiles\%time:~0,2%.%time:~3,2%.%time:~6,2%
PUSHD temporarily maps a drive letter to the specified UNC share (that does not require credentials, starting from Z: on up until it finds one that's available). POPD cancels the mapping. pushd \ComputerName\ShareName
prints out a tree view of all of the files and subfolders (and their files)