Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Can't delete file due to invalid file name

16 Jun 2012   #1
RobinSchouten

Windows 7 Ultimate 64-bit
 
 
Can't delete file due to invalid file name

Hey all!

I have a .png file on my secondary hard drive, which I cannot seem to delete. When I try to delete or rename it, it tells me: "The selected file name is invalid or too long".

I came across the programs Delinvfile and Unlocker, but they did not seem to work for me.

Appreciate any help!


My System SpecsSystem Spec
16 Jun 2012   #2
Ztruker

Windows 8 Core X64
 
 

Try this: Open an Elevated Command Prompt. Change to the directory (folder) the file is in. You do this using the cd command.
For instance, if the file is in your Pictures folder, you would enter:

cd C:\Users\xxxxxxxx\Pictures (xxxxxxxx is your account name)

Once in the right directory (folder), use the del command as follows to see if you can delete it. If, for instance, the file starts with asdfg0000....... etc,

del asdfg000*

That will delete any file that begins with the letters adsfg000, so be careful. Make sure you use enough of the beginning letters so the del command will only delete that file.
My System SpecsSystem Spec
16 Jun 2012   #3
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by RobinSchouten View Post
Hey all!

I have a .png file on my secondary hard drive, which I cannot seem to delete. When I try to delete or rename it, it tells me: "The selected file name is invalid or too long".

I came across the programs Delinvfile and Unlocker, but they did not seem to work for me.

Appreciate any help!
If you find a bunch of files don't want to delete in Explorer try scanning with Malwarebytes anti-malware. I had a registry hack that added NoModify to all files in Explorer. Malwarebytes got rid of it easily.

But it is quite possible to get filenames longer than Explorer can handle. In those cases use command line deletion.

Also if you search online there's a tool called TLPD.exe that searches for files with paths too long.
My System SpecsSystem Spec
17 Jun 2012   #4
RobinSchouten

Windows 7 Ultimate 64-bit
 
 

Quote   Quote: Originally Posted by Ztruker View Post
Try this: Open an Elevated Command Prompt. Change to the directory (folder) the file is in. You do this using the cd command.
For instance, if the file is in your Pictures folder, you would enter:

cd C:\Users\xxxxxxxx\Pictures (xxxxxxxx is your account name)

Once in the right directory (folder), use the del command as follows to see if you can delete it. If, for instance, the file starts with asdfg0000....... etc,

del asdfg000*

That will delete any file that begins with the letters adsfg000, so be careful. Make sure you use enough of the beginning letters so the del command will only delete that file.
Thanks, but I can't seem to cd to D:/...

How come?
My System SpecsSystem Spec
17 Jun 2012   #5
Dwarf

Windows 8.1 Pro RTM x64
 
 

You need to enter the /D switch in the command. This allows you to change the current drive in addition to the current directory. So the command after the prompt reads as follows (note that the switch needs to be entered as shown): cd /d d:\ This works from both an administrative and user command prompt, but remember that the context and scope of any subsequent commands that you perform on the drive/directory is still the same as that to which you executed CMD in the first place.
My System SpecsSystem Spec
17 Jun 2012   #6
RobinSchouten

Windows 7 Ultimate 64-bit
 
 

Ok, so I followed all your instructions, but it still does not work. I get a similar error: "The filename, directory name, or volume label syntax is incorrect".
My System SpecsSystem Spec
17 Jun 2012   #7
Ztruker

Windows 8 Core X64
 
 

Can you post the name of the file?
My System SpecsSystem Spec
17 Jun 2012   #8
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by RobinSchouten View Post
Ok, so I followed all your instructions, but it still does not work. I get a similar error: "The filename, directory name, or volume label syntax is incorrect".
Peculiar since when I google asdfg000 I get a bunch of references to online games, profiles and blogs. How about posting a screen shot of the folder showing the file or whatever it is, in the screen shot? Something is weird.
My System SpecsSystem Spec
17 Jun 2012   #9
RobinSchouten

Windows 7 Ultimate 64-bit
 
 

Quote   Quote: Originally Posted by MilesAhead View Post
Quote   Quote: Originally Posted by RobinSchouten View Post
Ok, so I followed all your instructions, but it still does not work. I get a similar error: "The filename, directory name, or volume label syntax is incorrect".
Peculiar since when I google asdfg000 I get a bunch of references to online games, profiles and blogs. How about posting a screen shot of the folder showing the file or whatever it is, in the screen shot? Something is weird.
That was a file name example given by Ztruker.

The file it's about is a .png desktop screenshot taken when I was dualbooting with Ubuntu. When I got rid of it, I copied all the files I wanted to keep to my secondary hard drive including this desktop screenshot. The other files act normally, but this one is not.

The file name is: "Schermafdruk_van_(time)_(date).png". Without the quotes and with the correct variables.
My System SpecsSystem Spec
17 Jun 2012   #10
karlsnooks

MS Windows 7 Ultimate SP1 64-bit
 
 

Robin,
Is this file in the Pictures folder?
You have given the name but not the path for the file.

Try following:
go to an elevated command prompt and enter following commands:
CD /D %userprofile%\Pictures
dir schmerafdruk*.*
does you trouble file show up?

Go To an Elevated Command Prompt


Elevated command prompt = Run CMD.EXE as administrator
WIN | type CMD.EXE | do not hit Enter |
CTRL+SHIFT+ENTER keycombo| YES

WIN is the key with the Microsoft flag on top.
My System SpecsSystem Spec
Reply

 Can't delete file due to invalid file name




Thread Tools





Similar help and support threads
Thread Forum
The Unattend answer file contains an invalid product key
I am responsible for building, updating, converting, building a sysprepped Windows 7 Pro master and deploy it on my company's computers. The final result is a build that includes full recovery capability, as most of these computers are used outside the office, some in remote locations. To...
Software
Windows 7 USB/DVD Download Tool Invalid ISO file
Hey, I downloaded a Windows 7 (x64) ISO file with my MSDNAA license. I want to create a bootable Windows 7 on my USB flash drive to install it on my new laptop. However, after I selected the ISO file and click on the "Next" button I got an error message: "Invalid ISO file - The selected ISO...
Installation & Setup
Help file wont delete win 7 says there is no file
I have a download that got interrupted and now have a file with extension .file that cant be deleted. Cleaning software wont catch it, restarting not working either. Havent tried a restore yet
General Discussion
File too long or invalid error.
Am copying mp3 files from an external ntfs hd partition to a local hd partition. fileA which is very long copies fileB mozart_drott_1allegro
General Discussion
Invalid BOOT.INI file
Hi, I've got an old computer that is running Windows XP that I've decided to upgrade to Windows 7. After a bit of trouble, I managed to get through the installation process. At least I think I've got through the installation process - the problem starts soon after the bit where you have to name...
Installation & Setup
Invalid boot.ini file
Hello all, two days ago I upgraded FROM windows vista ultimate TO windows 7 x86 ultimate on my HP pavillion dv9005us laptop. I had no problems on vista, and it worked fine after an upgrade to 7 for a day. And then it rebooted and goes through the window that gives you the option to change...
BSOD Help and Support

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:00.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App