Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Use of free form file names in Command Prompt

10 Jul 2011   #1
ffrree

Windows 7 64 bit Ultimate
 
 
Use of free form file names in Command Prompt

Can someone advise me how to specify files names that contains a space, e.g.

the name "this file" in Command Prompt.

I tried using " and ' to quote the file name, but none works

Thanks


My System SpecsSystem Spec
.
10 Jul 2011   #2
richnrockville

Windows 7 Pro x64 SP1
 
 

Quote   Quote: Originally Posted by ffrree View Post
Can someone advise me how to specify files names that contains a space, e.g.

the name "this file" in Command Prompt.

I tried using " and ' to quote the file name, but none works

Thanks
Welcome ffrree, long file names with embedded spaces require a full set of quotes
starting and ending with no spaces at the front or end.

cmd "xxx readme.exe"
if this was an executable.

or
c:\> copy "file1 stuff.doc" "rrr is a file name.doc"

will work
notice the starting and ending quotes.

Rich
My System SpecsSystem Spec
10 Jul 2011   #3
karlsnooks

MS Windows 7 Ultimate SP1 64-bit
 
 

ffrree,

Actually, in win 7 we do have a couple of changes.

As an example, go to a cmd prompt and type help cd

Here is part of what your will see:

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as
the on disk names. So CD C:\TEMP would actually set the current
directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, so it is possible to
CD into a subdirectory name that contains a space without surrounding
the name with quotes. For example:

cd \winnt\profiles\username\programs\start menu

is the same as:

cd "\winnt\profiles\username\programs\start menu"

which is what you would have to type if extensions were disabled.

Try it out by doing a
cd \program files

===============================

now what is the specific example which is giving you problems?
My System SpecsSystem Spec
.

10 Jul 2011   #4
unifex

Windows 7 Ultimate (x64)
 
 

There are some differences depending on which command line interpreter you are using. You can check the way your system behave by using the Tab key to fill in the rest of the file name (i.e. change your working directory to C:\ and type P then press the Tab key, or type D and press the tab key: the system will type the rest of the file (or folder) name automatically provided the name is unique). Do it once and you will know for sure.

On my PC I actively use two different prompts - the Windows command prompt and also the bash shell (powered by Cygwin). As you can see from the screnshot, the two handle spaces in the file names rather
differently.


Attached Images
 
My System SpecsSystem Spec
Reply

 Use of free form file names in Command Prompt




Thread Tools





Similar help and support threads
Thread Forum
File - Delete from Command Prompt
How to Delete a File in Windows from the Command Prompt This tutorial will show you how to permanently delete a File in Vista, Windows 7, or Windows 8 using the DEL or ERASE command from within a command prompt. This can be handy if you cannot delete the file normally.While you can run...
Tutorials
A file in Desktop cant be deleted. Command prompt doesnt recognize it.
The files name is "Music Place", which is an application from Toshiba. I can not find it in the desktop folder and all the programs that i have used are not able to recognize this file as existing in the desktop. Ive tried to delete it in safe mode but it didnt work. Ive also tried to delete it...
General Discussion
Command Line Prompt - How To Export List of Files to Text File
Hi guys, I have a folder with 995 files in it and I'd like to give someone a text file with a list of all these files in it. Is there a way that I can get the command line to send the names of these files to a text file? I tried navigating to the directory and using the DIR command and,...
General Discussion
Command Prompt missing File Menu
Hello! Any help would be appreciated: my command prompt window does not have a file menu. I also cannot manually resize the window. I am not sure what caused this, and I have tried F1-F12 to see if that would toggle a setting, but it did not make a change. Thanks for any help!
General Discussion
programmatic way with BAT file determining if elevated command prompt
Is there any programmatic way within a BATch file of determining whether it has been started from an elevated command prompt (run as Administrator) or a normal command prompt? I note the difference between the Current Directory at start of the BATch file, but wonder if there is a better way. ...
General Discussion
File and Folder - Rename from Command Prompt
How to Rename a File and Folder from the Command Prompt This will show you how to rename a file and folder using the REN or RENAME command from within a command prompt. This can be handy if you cannot rename the file or folder normally. Normally you would just right click on the file or...
Tutorials

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:34.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App