From: Andrew McLaren on
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
From: Pegasus [MVP] on


"Andrew McLaren" <andrew(a)somewhere.com> said this in news item
news:#B0LXTsnKHA.3664(a)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!


From: Jose on
On Jan 26, 3:23 am, Jake <jak...(a)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?
From: a on
"Pegasus [MVP]" <news(a)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).


From: John John - MVP on
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