TYPE – Windows CMD Command
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Display the contents of one or more text files.
1 2 3 |
Syntax TYPE [drive:]pathname(s) |
If more than one file is specified the filenames are included in the output.
If a wildcard is used the filenames are displayed even if only one file matches. The file names are printed to the error stream and so can be hidden by redirecting to NUL TYPE * 2>nul
Errorlevels
If the file(s) were successfully displayed %ERRORLEVEL% = 0
If the file was not found or bad parameters given %ERRORLEVEL% = 1
TYPE is an internal command.
Examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Redirect output into a new file: TYPE file.txt > Newfile.txt Append output to an existing file: TYPE file.txt >> ExistingFile.txt To do the same with user console input : TYPE CON > Newfile.txt |
This will require typing a CTRL-Z to indicate the end of file.
When using redirection to SORT a file the TYPE command is used implicitly
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SORT < MyFile.txt Create an empty (zero byte) file: TYPE nul >filename.log Check filesize during a download (to monitor progress of a large download) Since TYPE won't lock the file, this does not pose a threat to the download completing successfully: TYPE file_being_downloaded >NUL DIR file_being_downloaded Convert an ASCII (Windows1252) file into a Unicode (UCS-2 le) text file: For /f "tokens=2 delims=:" %%G in ('CHCP') do Set _codepage=%%G CHCP 1252 >NUL CMD.EXE /D /A /C (SET/P=ÿþ)<NUL > unicode.txt 2>NUL CMD.EXE /D /U /C TYPE ascii_file.txt >> unicode.txt CHCP %_codepage% |
The technique above (based on a script by Carlos M.) first creates a file with a Byte Order Mark (BOM) and then appends the content of the original file. CHCP is used to ensure the session is running with the Windows1252 code page so that the characters 0xFF and 0xFE (ÿþ) are interpreted correctly.
It is also possible to convert files from Unicode to ASCII with TYPE or MORE see the redirection syntax page for details.