Filename too long - unable to delete file


Recently I downloaded a few .mpg files through KaZaa, when i tried to open them, windows media player opened up a webpage instead. When i then tried to delete them by clicking on the filename and pressing Delete, nothing happens.
I checked the filename and it seems like the filename is extremely long and it is disguised to be short. It goes like "abc.mpg                 fgf sfgsfd fdsg.mpg" -- notice the tons of spaces in the filename.
I tried to delete the file in Command Prompt and got a "The filename or extension is too long" error.

Can anyone tell me how to handle such files? Thanks
Who is Participating?
CrazyOneConnect With a Mentor Commented:
Ok open the Command Prompt window. Now move to the folder where these file are by using the CD command Example:
CD c:\TheFolder
Now run this command
dir /x
This will give a list of the short file names like abcdefg~.mpg. And then delete the file using the short file name.

The Crazy One
It's unlikely the file name alone is too long, just that in conjunction with the full path the result is too long.

From DOS, CD to the directory and try a del abc.mpg*.mpg
If there are other files that may match that mask, move them to some other directory first.
Gotta love cross posts.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

PS: Shows you how much I know, I didn't think XP had short names
Actually what I suspect is happening is that the file name has some characters that are invalid to Explorer and these characters look like spaces sometimes. Hackers love to do this especially when they find a machine they can break into. They will create folders with invalid characters making the deletion of the folders a not so easy task. They are hoping the mahcine they hacked that the user isn't aware the short file name trick.
Did you try to rename the files. Right click on the file and select Rename and see if it allows you to rename the file. If not then the file name does have invalid characters in it that Explorer just doesn't know how to deal with.
Exactly. I just had a client who couldn't delete some files because of some bogus error and the problem was that someone (the last administrator) actually (somehow) created the filenames with characters that could not be used in a filename or directory name. I think it was an apostrophe but I'm not sure. I would try renaming the file. If that doesn't work, rename the directory beneath it that possibly has a strange character if one exists.
SelconAuthor Commented:
Yep, that worked! thanks =)
I tried renaming the file to a shorter name, but win xp just doesnt let me.
You are welcome. :>)
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.