CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • Dos Prompt rename a file with spaces in the name using wildcards

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    32
  • Date Created
    Sunday, October 10, 2010
  • Last Updated
    Tuesday, November 16, 2010
  • This Article Has been Viewed
    6140 times
  • Short Desc
    Renaming a file with spaces in the name will give you an error when using a Dos Prompt or Command Prompt.
  • Details
    When using a dos prompt or command prompt and trying to rename a file which has spaces in the name: my file.txt will result in an error
    The syntax of the command is incorrect.

    The use of Wildcards will be needed in order to rename your spaced files and folders
  • Recreate Issue
    To recreate this issue, perform the following action in a command prompt
    Substituting the U:\Files
    For your actual drive and folder path.

     
    U:\Files\rename my file.txt my file.doc

    The syntax of the command is incorrect.
  • Resolve Issue
    To properly write out the dos command to rename your file with spaces, perform the following action.
    (This will come in handy if you are unable to rename the file in windows do to the file being in use)

     
    U:\Files\rename my?file.txt my?file.doc


    As you can see above, we have added in a Question Mark ?
    In place of the spaces in the name of the file.
    What this does is give a legal dos filename character.
    If you leave the ? mark off from the output filename like this

     
    U:\Files\rename my?file.txt my file.doc


    The output renamed file will be my_file.doc
    See, the ? in the original filename with add an underscrore to the output filename.
    But adding in the ? in the output filename, makes it so that you can rename the file with the original space still in tact.