This article was previously published under Q65163
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Although your application program may allow you to enter a filename ordirectory name that contains a space character, MS-DOS does not allowfilenames or directory names to have spaces in them.
If you create a filename containing a space, you cannot subsequentlyremove, load, or delete the file unless you first rename it.
For example, if the file appears in the directory as
TEST CAR TXT 4098 01-01-80 3:10pm
then MS-DOS does not allow you to manipulate the file unless youdelete the space between "TEST" and "CAR."
If you create a directory name with a space in it, you must remove thedirectory.
When MS-DOS parses the command line, it separates the variousparameters by looking for a space. MS-DOS commands and utilities viewthe filename "AUG 1990.DAT" as two parameters: "AUG" and "1990.DAT."Commands such as ERASE, COPY, and RENAME return an invalid parametererror because it appears that an extra parameter is supplied.
Also, certain operations that application software can request MS-DOSto perform require a filename. If the filename supplied to MS-DOS bythe application contains a space, MS-DOS may be unable to process therequest.
Modifying/Removing a File
Use the following procedure to rename and then modify a file with aspace in its name:
Use the MS-DOS RENAME command with a wildcard to replace the space with a legal filename character. For example:
rename test?car.txt test_car.txt
This example replaces the space with the underscore character.
This method prevents MS-DOS from separating TEST and CAR.TXT as two separate parameters, but still allows MS-DOS to find the file. The file is renamed to TEST_CAR.TXT, which is a legal MS-DOS filename.
Delete, read, or modify the file using normal procedures.
Removing a Directory
You can remove a directory that contains a space in its name by usingthe Basic interpreter, which is included in MS-DOS (GW-Basic, BASICA,or QBasic).
Start GW-Basic, BASICA, or QBasic, by typing its name and pressing ENTER.
In QBasic, press F6 to make the Immediate window active (this step is not necessary in GW-Basic or BASICA).
Use the MS-DOS RMDIR command to remove the directory. For example, use the following command to remove a directory called "HI THERE":
rmdir "hi there" (and press ENTER)
GW-Basic or BASICA respond with "OK"; QBasic does not respond.
To exit QBasic, choose Exit from the File menu; to exit GW-Basic or BASICA, type system and press ENTER.
NOTE: If you are using MS-DOS 6.0, 6.2, or 6.21, you can use MOVE to renameillegal directories. For example, type the following at the MS-DOS commandprompt:
move "my work" my_work
The user's guides for all Microsoft MS-DOS versions contain a sectionon valid MS-DOS filenames.
"Microsoft MS-DOS User's Guide and User's Reference version 4.0," page 16 "Microsoft MS-DOS User's Guide and Reference version 5.0," page 69 "Microsoft MS-DOS User's Guide versions 6.0-6.21," page 35 "Microsoft MS-DOS Upgrade User's Guide version 6.22," page 35