1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Delete filename with trailing space..

Discussion in 'Windows XP' started by Jake, Jan 26, 2010.

  1. Jake

    Jake Flightless Bird

    Help...

    How do I delete a file / folder in XP which has a trailing space...?

    regards jake
     
  2. Andrew McLaren

    Andrew McLaren Flightless Bird

    On 26/01/2010 19:23, Jake wrote:

    > How do I delete a file / folder in XP which has a trailing space...?



    Hi Jake

    Put quotes around the file name. For example from a command line:


    C:/SOMEDIR>del "this is a file with a trailing space "

    or

    C:/>rmdir "this is a folder with a trailing space "


    Note the trailing space, in these commands :)

    Hope it helps,

    Andrew

    --
    amclar at optusnet dot com dot au
     
  3. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "Jake" <jake44@gmail.com> said this in news item
    news:u5R3ODmnKHA.4628@TK2MSFTNGP06.phx.gbl...
    > Help...
    >
    > How do I delete a file / folder in XP which has a trailing space...?
    >
    > regards jake


    AFAIK, Windows allows file or folder names with *embedded* spaces but not
    with *trailing* spaces. How exactly did you work out that you had a name
    with a trailing space?
     
  4. a

    a Flightless Bird

    "Pegasus [MVP]" <news@microsoft.com> wrote

    > AFAIK, Windows allows file or folder names with *embedded* spaces but not with *trailing* spaces.


    Huh? Of course files and folders can have spaces at their start or end.

    > How exactly did you work out that you had a name with a trailing space?


    By seeing the blank space in the focus rectangle when selected.
     
  5. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "a" <b@invalid.com> said this in news item
    news:4b5ecabc$1@dnews.tpgi.com.au...
    > "Pegasus [MVP]" <news@microsoft.com> wrote
    >
    >> AFAIK, Windows allows file or folder names with *embedded* spaces but not
    >> with *trailing* spaces.

    >
    > Huh? Of course files and folders can have spaces at their start or end.
    >
    >> How exactly did you work out that you had a name with a trailing space?

    >
    > By seeing the blank space in the focus rectangle when selected.


    This can be deceptive. The white space could be $FF. It looks the same as a
    space but it isn't.
     
  6. Andrew McLaren

    Andrew McLaren Flightless Bird

    On 26/01/2010 21:37, Pegasus [MVP] wrote:
    >> How do I delete a file / folder in XP which has a trailing space...?

    > AFAIK, Windows allows file or folder names with *embedded* spaces but
    > not with *trailing* spaces. How exactly did you work out that you had a
    > name with a trailing space?


    With respect ... actually, NTFS has no problem creating a file with a
    trailing space in the name. However Windows Explorer, CMD.EXE and
    OS-supplied utilities will usually trim any trailing spaces from a file
    name when they manipulate a file. So, yes: a trailing space is rare. But
    any app can decide to do:

    hFile = CreateFile("My funnny file " // file name
    <...> // other params
    FILE_ATTRIBUTE_NORMAL, // normal file
    NULL);

    ....and create a file with a trailing space in its name.

    Trailing spaces are explicitly deprecated in the Windows SDK's file
    naming convention guidelines; but there's nothing to actually stop
    someone from doing it.

    You are correct that the U+00A0 "No break space" char can also look like
    a space, and is indeed legal at the end of file names.

    Apologies for being a pedantic pain-in-the-butt, but ... I get all
    pedantic, sometimes :)

    Cheers

    Andrew

    --
    amclar at optusnet dot com dot au
     
  7. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "Andrew McLaren" <andrew@somewhere.com> said this in news item
    news:#B0LXTsnKHA.3664@TK2MSFTNGP04.phx.gbl...
    > On 26/01/2010 21:37, Pegasus [MVP] wrote:
    >>> How do I delete a file / folder in XP which has a trailing space...?

    >> AFAIK, Windows allows file or folder names with *embedded* spaces but
    >> not with *trailing* spaces. How exactly did you work out that you had a
    >> name with a trailing space?

    >
    > With respect ... actually, NTFS has no problem creating a file with a
    > trailing space in the name. However Windows Explorer, CMD.EXE and
    > OS-supplied utilities will usually trim any trailing spaces from a file
    > name when they manipulate a file. So, yes: a trailing space is rare. But
    > any app can decide to do:
    >
    > hFile = CreateFile("My funnny file " // file name
    > <...> // other params
    > FILE_ATTRIBUTE_NORMAL, // normal file
    > NULL);
    >
    > ...and create a file with a trailing space in its name.
    >
    > Trailing spaces are explicitly deprecated in the Windows SDK's file naming
    > convention guidelines; but there's nothing to actually stop someone from
    > doing it.
    >
    > You are correct that the U+00A0 "No break space" char can also look like a
    > space, and is indeed legal at the end of file names.
    >
    > Apologies for being a pedantic pain-in-the-butt, but ... I get all
    > pedantic, sometimes :)


    .. . . which goes to show that just because I am unable to do a certain thing
    does not mean that it can't be done. Thanks for the clarification!
     
  8. Jose

    Jose Flightless Bird

    On Jan 26, 3:23 am, Jake <jak...@gmail.com> wrote:
    > Help...
    >
    > How do I delete a file / folder in XP which has a trailing space...?
    >
    > regards jake


    How did you determine that the file / folder has a trailing space, how
    are you trying to delete it (Windows Explorer?), do you get any kind
    of error message stating the attempt failed and if you do, what is the
    message?
     
  9. a

    a Flightless Bird

    "Pegasus [MVP]" <news@microsoft.com> wrote
    >>> AFAIK, Windows allows file or folder names with *embedded* spaces but not with *trailing* spaces.

    >>
    >> Huh? Of course files and folders can have spaces at their start or end.
    >>
    >>> How exactly did you work out that you had a name with a trailing space?

    >>
    >> By seeing the blank space in the focus rectangle when selected.

    >
    > This can be deceptive. The white space could be $FF. It looks the same as a space but it isn't.


    It's not $FF, it's $20. I did it myself via my own application. (It was actually
    a bug in my app that led to two filenames having a leading space, due to a bad
    crop of their names).
     
  10. John John - MVP

    John John - MVP Flightless Bird

    Jake wrote:
    > Help...
    >
    > How do I delete a file / folder in XP which has a trailing space...?


    At a command prompt:

    del "\\?\c:/path_to_file_that contains a trailing space.txt "

    To avoid path errors it's easier to grab the file with Windows Explorer
    and then drop it at the command prompt, type the partial command:

    del \\?\

    then drop the grabbed file to the prompt. Pay attention to the path's
    "quotation marks".

    John
     

Share This Page