Author Options:

what are all the best batch file comands? Answered

witch commands are the best and easiest to use


i made a batch file with about all the commands i could find
so did i just answer my own question?
(copy and paste alot of help)
@echo off
title batch command help
color 0e
echo here are a lot of batch commands
echo have fun
pause > nul
echo ASSOC     Displays or modifies file extension associations. 
echo ATTRIB     Displays or changes file attributes. 
echo GRAFTABL     Enables Windows to display an extended character set in graphics mode. 
echo BREAK     Sets or clears extended CTRL+C checking. 
echo CACLS     Displays or modifies access control lists (ACLs) of files. 
echo CALL     Calls one batch program from another. 
echo CD     Displays the name of or changes the current directory. 
echo CHCP     Displays or sets the active code page number. 
echo CHDIR     Displays the name of or changes the current directory. 
echo CHKDSK     Checks a disk and displays a status report. 
echo CHKNTFS     Displays or modifies the checking of disk at boot time. 
echo CLS     Clears the screen. 
echo CMD     Starts a new instance of the Windows command interpreter. 
echo COLOR     Sets the default console foreground and background colors. 
echo COMP     Compares the contents of two files or sets of files. 
echo COMPACT     Displays or alters the compression of files on NTFS partitions. 
echo CONVERT     Converts FAT volumes to NTFS. You cannot convert the current drive. 
echo COPY     Copies one or more files to another location. 
echo DATE     Displays or sets the date. 
echo DEL     Deletes one or more files. 
echo DIR     Displays a list of files and subdirectories in a directory. 
echo DISKCOMP     Compares the contents of two floppy disks. 
echo DISKCOPY     Copies the contents of one floppy disk to another. 
echo DOSKEY     Edits command lines, recalls Windows commands, and creates macros. 
echo ECHO     Displays messages, or turns command echoing on or off. 
echo ENDLOCAL     Ends localization of environment changes in a batch file. 
echo ERASE     Deletes one or more files. 
echo EXIT     Quits the CMD.EXE program (command interpreter). 
echo FC     Compares two files or sets of files, and displays the differences between them. 
echo FIND     Searches for a text string in a file or files. 
echo FINDSTR     Searches for strings in files. 
echo FOR     Runs a specified command for each file in a set of files. 
echo FORMAT     Formats a disk for use with Windows. 
echo FTYPE     Displays or modifies file types used in file extension associations. 
echo GOTO     Directs the Windows command interpreter to a labeled line in a batch program. 
echo AT     Schedules commands and programs to run on a computer. 
echo HELP     Provides Help information for Windows commands. 
echo IF     Performs conditional processing in batch programs. 
echo LABEL     Creates, changes, or deletes the volume label of a disk. 
echo echo MD     Creates a directory. 
echo MKDIR     Creates a directory. 
echo MODE     Configures a system device. 
echo MORE     Displays output one screen at a time. 
echo MOVE     Moves one or more files from one directory to another directory. 
echo PATH     Displays or sets a search path for executable files. 
echo PAUSE     Suspends processing of a batch file and displays a message. 
echo POPD     Restores the previous value of the current directory saved by PUSHD. 
echo PRINT     Prints a text file. 
echo PROMPT     Changes the Windows command prompt. 
echo PUSHD     Saves the current directory then changes it. 
echo RD     Removes a directory. 
echo RECOVER     Recovers readable information from a bad or defective disk. 
echo REM     Records comments (remarks) in batch files or CONFIG.SYS. 
echo REN     Renames a file or files. 
echo RENAME     Renames a file or files. 
echo REPLACE     Replaces files. 
echo RMDIR     Removes a directory. 
echo SET     Displays, sets, or removes Windows environment variables. 
echo SETLOCAL     Begins localization of environment changes in a batch file. 
echo SHIFT     Shifts the position of replaceable parameters in batch files. 
echo SORT     Sorts input. 
echo START     Starts a separate window to run a specified program or command. 
echo SUBST     Associates a path with a drive letter. 
echo TIME     Displays or sets the system time. 
echo TITLE     Sets the window title for a CMD.EXE session. 
echo TREE     Graphically displays the directory structure of a drive or path. 
echo TYPE     Displays the contents of a text file. 
echo VER     Displays the Windows version. 
echo VERIFY     Tells Windows whether to verify that your files are written correctly to a disk. 
echo VOL     Displays a disk volume label and serial number. 
echo XCOPY     Copies files and directory trees. 


8 years ago

Click on Start, followed by Run, and type "CMD". Press OK, and you should see a DOS box. Type HELP, press Enter and you wiil get an overview with short descriptions. Type [command] /? (e.g. FOR /?) to get detailed informations.

See also "HELP CMD".

Also, note that many of the batch commands can be used from the command line too. For example, you could do
    for %f in (*.bat *.cmd) do @find "bat" %f
to apply the find command to all .bat and .cmd files in the current directory. (Yes, you could do that  without the for loop; I'm just demonstrating the idea.)

HELP CMD is just the same as CMD /? (how I wrote before).
Your example is wrong to show all *.bat and *.cmd files in the current folder because the FIND command is not necessary and looks only for "bat". Thats why

-for the command line:
for %f in (*.bat *.cmd) do @echo %f

-and for using in batch files:
for %%f in (*.bat *.cmd) do @echo %%f

Those are DOS commands.  Do they work in a batch file?  It's been so long since I used either I can't remember.

A batch file contains nothing more then DOS command lines. And YES, all the commands do work in a batch file.

Here is a list of the commands.

It doesn't matter which ones are the easiest.  It only matters what you want them to do.  If you don't know how to use the ones you need then you aren't going to be able to do what you want to do.