Thread: Issues with spaces in folder names when using CMD prompt

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Issues with spaces in folder names when using CMD prompt

    Hi Guys

    I wonder if you can help ... I have a folder that I want to export the file names within into a text file. The problem I'm having is that because the path of the file has spaces in it, it's not working correctly, and after searching the internet I can't seem to fix the problem.

    For example the following works fine: (please note that I have had to remove the "my" from "my documents" to make it work ... which i also do not understand)

    dir C:\Users\Megan\Documents\Documents\fun\ >C:\Users\Megan\Documents\Documents\fun\filelist.t xt

    Could somebody please tell me how to edit the following so this works too (which shows the true path of the folder):

    dir C:\Users\Megan\My Documents\My Documents\BV BioSculpture Manicures\Financials\Receipts\ >C:\Users\Megan\My Documents\My Documents\BV BioSculpture Manicures\Financials\Receipts\Filelist.txt

    Thanks for your help guys ... And apologies if this is a simple question ... but anything involving the CMD Prompt is not my forte!

    Thanks

    Megan x

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Surround the path with double quote characters.

    dir "C:\Users\Megan\My Documents\My Documents\BV BioSculpture Manicures\Financials\Receipts\" >"C:\Users\Megan\My Documents\My Documents\BV BioSculpture Manicures\Financials\Receipts\Filelist.txt"
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    2
    Hi Grumpy

    I tried that but annoyingly it didn't work ... then just on the off chance i deleted the "my"s from the 2 folders named "My Documents" ... and bingo ... so thanks for your help

    My question would then be, why does the CMD Prompt not like the work "my", which seems very strange considering the folders name is "my documents", and especially when the second folder was created by myself?

    Thanks

    Megan X

  4. #4
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Because Windows Vista and 7 changed their names. Hence why you are accessing the paths via 'C:\Users' and not 'C:\Documents and Settings'

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by Megan2682 View Post
    My question would then be, why does the CMD Prompt not like the work "my", which seems very strange considering the folders name is "my documents", and especially when the second folder was created by myself?
    Starting with Windows Vista, the name "My Documents" was changed to "Documents". However, for backwards compatibility, the "My" prefix had to remain somehow. This would allow older programs that depended on this folder to find it.

    If you type the following on a console you'll get a file not found message:
    Code:
    dir C:\Users\Megan\My Documents\
    Whereas without the "My" prefix you do see your Documents folder contents. If you the go to Windows Explorer and navigate to that location, it shows the folder named as "My Documents". This I agree is confusing as hell. What is going on is that "My Documents" is in fact a Junction Point. An alias to the name Documents. Starting with Windows Vista, "My Documents" doesn't actually exist. It simply points to the actual folder named "Documents". Older applications can thus still function. So, from Windows Vista onwards, you should always use "Documents" instead of "My Documents".

    So, what about the second folder, the "My Documents" you created yourself? Here's where you need to provide more information on how you actually created that folder. For all purposes, the name "My Documents" is a valid name. Both the windows console and explorer allow me to create "My Documents" inside the "Documents" folder. So what you are saying about the second folder doesn't make sense unless something else happened.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading folder names..how is it done ?
    By roalme00 in forum C++ Programming
    Replies: 8
    Last Post: 01-11-2008, 10:34 AM
  2. How to get names to all files/folders in a folder?
    By Marcux in forum C Programming
    Replies: 5
    Last Post: 04-22-2007, 11:41 AM
  3. How to get names of folders in specific folder
    By bikr692002 in forum Windows Programming
    Replies: 17
    Last Post: 09-04-2006, 02:57 PM
  4. how to get names of files in folder
    By kiku in forum C++ Programming
    Replies: 3
    Last Post: 03-07-2005, 06:51 PM
  5. is there a way to write the file names in a folder in a text file?
    By Commander in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 08-15-2002, 05:11 PM

Tags for this Thread