Windows 7 / Getting Started

Arguments, Commas, and Quotes

When a command-line program requires you to specify information such as the name of a file to process or an option to use, you usually type this information after the command name with the items separated by spaces. For example, the delete command erases the file or files named on its command line:

delete somefile.txt anotherfile.txt

You can also separate command-line arguments with the semicolon (;) or comma (,), but this is not recommended; CMD accepts this to be compatible only with good old COMMAND.COM.

Unfortunately, because Windows filenames can contain spaces in the middle of the name, the command

delete c:\Users\bknittel\Documents\My Music\mpeg files\files.txt

attempts to delete three files: C:\Users\bknittel\Documents\My, Music\mpeg, and files\files.txt.To solve this problem, CMD interprets quotation marks (") to mean that the text enclosed is to be treated as part of one single argument. For example, the command

delete "c:\Users\bknittel\Documents\My Music\mpeg files\files.txt"

deletes the one indicated file.The quotation marks are not seen as part of the filename; they just keep it all together.

[Previous] [Contents] [Next]