• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

Delete filename with trailing space..

J

Jake

Flightless Bird
Help...

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

regards jake
 
A

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
 
P

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?
 
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.
 
P

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.
 
A

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
 
P

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!
 
J

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?
 
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).
 
J

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
 
Top