Problem with deleting folders

I run an ftp, and lately have run into a strange problem.  Someone has uploaded folders that I cannot delete.  These folders have a space at the end of the the name, so I cannot delete, rename, move, or do anything to them.

Anyone know any tricks to get rid of this problem? (without formatting)

Who is Participating?
NetminderConnect With a Mentor Commented:
Per recommendation, points refunded and question closed.

CS Moderator
WakeupSpecialist 1Commented:
What OS?  are you trying to delete them from a GUI interface or a Dos interface?  or through the FTP?

What happens when you try and delete it?  get any error messages?
My suggestion is if you have a GUI interface, just drag it to the recycle bin....or highlight it and hit Delete.  
Or, you can right mouse click on it and choose delete.
what happens when you try either of these routes?

Give us a little more info so we can help ya out.
Try with quotes to delete these files.
Like "filename.ext " ?
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

What OS? What error message do u get? What kind of file system do u have for the drive on which these folders are created? Check the security properties of these folders. If it is NT/2000 take the ownership of the folders and then try to delete them.
If the drive is accessible from DOS (not command prompt, actual DOS) then you can delete them without a problem. Just a suggestion...kicking in the DARK!!!!!
See if you can rename the directory. What is the directory name anyway's?

ren oldname newname

then del newname

let us know if any of these work will ya?
Some more to try:

if you have fat file system try this:

say your directory name is this: directory (space)
then type in this in a command prompt:

rmdir directory?

this will remove ALL directories that are named directory(then something else).

I just created a test folder on my c:\ and used the rmdir command to delete it with no switches or parameters at all...worked for me...what exactly IS the file name?
Crap, I just realized that we don't even know the OS involved here. If it's *nix then it should be quite easy, if it's winblows then it may take a few years, millions of dollars in research and lots, and lots, of chips and pepsi, but we'll eventually get it...
For NT.2k/XP

JSI tip 2057 I went to the command line, switched to the directory and typed -- RD /S
    "" This removed the offending directories and files (with names nt doesn't like) per and in similar
      fashion to, what Tim Holman offered above which would probably have the same result.

I hope this helps !
Ok I think what has happened is that the hacker has added a character to the end of the folder that Explorer does not recognize.

Try this open a command window and do this

If NT Win2000 or XP Open a CMD.EXE window. If Win9x-ME open COMMAND.COM.
CD to the top of the mess.
Use: DIR /X /A   to see the SHORT FILE NAMES of the files and directories there.
Use a combination of CD, RD, and DEL and the SHORT FILES names reported with DIR /X to delete your
way to the bottom and then back up the tree removing the files on the way down and the directories on
the way up.
Most likely there is NOT a protection issue here so you shouldn't need worry about ownership or file

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

   /S      Removes all directories and files in the specified directory
           in addition to the directory itself.  Used to remove a directory

   /Q      Quiet mode, do not ask if ok to remove a directory tree with /S

This MS KB article may help


How to Remove Files with Reserved Names in Windows (Q120716)

The information in this article applies to:

Microsoft Windows 2000 , Professional
Microsoft Windows 2000 , Server
Microsoft Windows 2000 , Advanced Server
Microsoft Windows 2000 , Datacenter Server
Microsoft Windows NT Server versions 3.1 , 3.5 , 3.51 , 4.0
Microsoft Windows NT Workstation versions 3.1 , 3.5 , 3.51 , 4.0
Microsoft Windows NT Advanced Server

Because applications control the policy for creating files in Windows, files sometimes are created with illegal or reserved names, such as LPT1 or PRN. This article explains how to delete such files using the standard user interface.

NOTE : You must be logged on locally to the Windows computer to delete these files.

If the file was created on a file allocation table (FAT) partition, you may be able to delete it under MS-DOS using standard command line utilities (such as DEL) with wildcards. For example:




These commands do not work on an NTFS partition as NTFS supports the POSIX subsystem and filenames such as PRN are legal under this subsystem. However, the operating system assumes the application that created them can also delete them; therefore, you can use commands native to the POSIX subsystem.

You can delete (unlink) these files using a simple, native POSIX application. For example, the Windows Resource Kit includes such a tool, Rm.exe.

NOTE : POSIX commands are case sensitive. Drives and folders are referenced differently than in MS-DOS. Windows 2000 and later POSIX commands must use the following usage syntax:
posix /c <path\command> [<args>] IE: posix /c c:\rm.exe -d AUX.

Usage assumes Rm.exe is either in the path, or the current folder:
rm -d // driveletter / path using forward slashes / filename
For example, to remove a file or folder named COM1 (located at C:\Program Files\Subdir in this example), type the following command:
rm -d "//C/Program Files/Subdir/COM1"
To remove a folder and its entire contents (C:\Program Files\BadFolder in this example), type the following command:
rm -r "//C/Program Files/BadFolder"
Another option is to use a syntax that bypasses the normal reserve-word checks altogether. For example, you can possibly delete any file with a command such as:
DEL \\.\ driveletter :\ path \ filename
For example:

DEL \\.\c:\somedir\aux

Published Jun 3 1997 7:28AM  Issue Type  
Last Modifed Dec 22 2001 12:57PM  Additional Query Words 3.10 prodnt CON PRN AUX CLOCK$ NUL COM1 LPT1 LPT2 LPT3 COM2 COM3 COM4 winnt  
Keywords kbusage  

COPYRIGHT NOTICE. Copyright 2002 Microsoft Corporation, One Microsoft Way, Redmond, Washington 98052-6399 U.S.A. All rights reserved.


The Crazy One
I created special charactor folders using telnet on a win2k system yesterday and had no problems whatsoever deleting them from Win2k, no special switches or anything like that...also, created a folder named test(hit space bar at end of name-then enter to apply the named space(space bar))had no problems deleting that either using the cmd it must be win98
lwinkenbAuthor Commented:
Sorry about the shortage of information:

The OS is Microsoft Windows 2k Server

Since the file system is ntfs, any DOS tricks are out of the question.  I realize I can use a utility like system commander to convert the file system to fat32, but Im hoping there is an alternative solution.

Unfortunatly I am late for work right now, so I can try any of the ideas given above yet.  Will let you know if anything works later in the day.

So, this is really starting to bug me:

do this:

get yourself a linux boot floppy, you MUST know someone running linux...

then, use it to boot your PC

then mount the ntfs partition like this:

mount -t ntfs /dev/hdaX /mnt

(where X is the number of your drive, primary master in windows is hda0 and every drive is incremented by 1, so hda2,hda3,hda4 etc.etc,etc
As long as you are able to boot into the server you most certainly can use the methods I outlined. I know it works  Just open cmd.exe and follow the intructions closely.
We had a machine getting hit approximately like this, and the buggers who did it also did some damage to the CMD.EXE file. The box is still sitting in a corner waiting for a reinstall.... I'll listen to this with interest...

OH YEAH, once you get onto the NTFS mount using the linux boot disk, cd to the directory where the file resides and type this at $ rmdir -rf <filename>

rm is remove -r = recursively(deletes all files and directories below specified dir to delete)

-f is to force the removal of the directory no matter what...


BTW---we still don't know the file name, take a screen shot and upload it to the web if you have to, we'd like to see it...
lwinkenbAuthor Commented:
Well, unfortunatly the problem was worse than I thought.  Instead of it just being an undeletable folder, it turned into tens of thousands of undeletable folders.  There must have been a virus somewhere that kept creating new folders in the old ones.

I tried all of the ideas listed here (actually, I didn't get around to using a linux disk to mount the drive), and nothing worked.  Using short file names didnt even work.  At this point my server drive was out of free space, and I had to solve the problem fast.  I ended up having to use system commander to convert the file system to FAT32, and then delete the folders that way.

Sorry I didn't have the time to let you guys come up with some more ideas, but the server had already been down 2 days, and that is 2 days too many.
Yes agreed, linux disk would worked if you did the following command:

rm -rf /path/to/directory

It appears that this question has been abandoned.  Please take a moment to finalize the question & reward your points as appropriate.  If this question is not finalized within 7 days, Community Support will be requested to force close it.  Unless there is objection or further activity,  it will also be requested that points be awarded to the following expert(s) for their comments:

N/A; situation resolved by asker

If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post a request in Community support (with a link to this page) to refund your points.  The link to the Community Support area is:


I ran into the same problem on my system.  Here is what solved it for me:
From a cmd prompt type the following command with this syntax: del "\\?\c:\dir_name_with_trailing_space "

i ran the rmdir /s command on a hackers directory on my computer through the command prompt.. It worked perfectly! Thanx guys!

just an fyi, i had a similar problem and CrazyOne's solution worked perfectly without much effort...i think he/she should be getting these points
i also posted crazyone's response to:

yeh it worked
lwinkenbAuthor Commented:
None of his suggestions worked for me at the time, which is why I didnt award the points.  Plus you're about a year and a half too late on your suggestion.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.