Solved Can't delete file due to invalid file name

stevepoolstock

New member
Local time
5:08 PM
Messages
67
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 Computer My Computer

At a glance

Windows 7 Pro
OS
Windows 7 Pro
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 Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
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 Computer My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
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 Computer My Computer

At a glance

Windows 7 Pro
OS
Windows 7 Pro
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 Computer My Computer

At a glance

Windows 8.1 Pro RTM x64Intel Core-i5-3570K 4-core @ 3.4GHz (Ivy Brid...4 x 4GB DDR3-1600 Corsair Vengeance CMZ8GX3M2...MSI GeForce GTX770 Gaming OC 2GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dwarf Dwf/11/2012 r09/2013
OS
Windows 8.1 Pro RTM x64
CPU
Intel Core-i5-3570K 4-core @ 3.4GHz (Ivy Bridge) (OC 4.4GHz)
Motherboard
ASRock Z77 Extreme4-M
Memory
4 x 4GB DDR3-1600 Corsair Vengeance CMZ8GX3M2A1600C9B (16GB)
Graphics Card(s)
MSI GeForce GTX770 Gaming OC 2GB
Sound Card
Realtek High Definition on board solution (ALC 898)
Monitor(s) Displays
ViewSonic VA1912w Widescreen (VGA)
Screen Resolution
1440x900
Hard Drives
OCZ Agility 3 SSD 120GB SATA III x2 (RAID 0)
Samsung HD501LJ 500GB SATA II x2
Hitachi HDS721010CLA332 1TB SATA II
Iomega 1.5TB Ext USB 2.0
WD 2.0TB Ext USB 3.0
PSU
XFX Pro Series 850W Semi-Modular
Case
Gigabyte IF233
Cooling
1 x 120mm Front Inlet 1 x 120mm Rear Exhaust
Keyboard
Microsoft Comfort Curve Keyboard 3000 (USB)
Mouse
Microsoft Comfort Mouse 3000 for Business (USB)
Internet Speed
NetGear DG834Gv3 ADSL Modem/Router (Ethernet) ~4.0 Mb/s (O2)
Antivirus
Avast! 8.0.1497
Browser
IE 11
Other Info
Optical Drive: HL-DT-ST BD-RE BH10LS30 SATA Bluray
Lexmark S305 Printer/Scanner/Copier (USB)
WEI Score: 8.1/8.1/8.5/8.5/8.25
Asus Eee PC 1011PX Netbook (Windows 7 x86 Starter)
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 Computer My Computer

At a glance

Windows 7 Pro
OS
Windows 7 Pro
Can you post the name of the file?
 

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
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 Computer My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
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 Computer My Computer

At a glance

Windows 7 Pro
OS
Windows 7 Pro
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 Computer My Computer

At a glance

MS Windows 7 Ultimate SP1 64-bitAMD A10-4600M6.00 GB Dual-Channel DDR3 @ 798MHz (11-11-12-28)AMD Radeon HD 7660G
Computer Manufacturer/Model Number
Toshiba Satellite S875D-S7239 laptop
OS
MS Windows 7 Ultimate SP1 64-bit
CPU
AMD A10-4600M
Motherboard
AMD Pumori (Socket FT1)
Memory
6.00 GB Dual-Channel DDR3 @ 798MHz (11-11-12-28)
Graphics Card(s)
AMD Radeon HD 7660G
Sound Card
High Definition Audio Device
Monitor(s) Displays
Generic PnP Monitor (1600x900@60Hz)
Screen Resolution
1600x900@60Hz
Hard Drives
SSD 119GB Corsair CSSD-V128GB2 ATA Device
Keyboard
Standard PS/2 Keyboard
Mouse
HP Wireless Optical Mobile Mouse Model FHA-3410
Internet Speed
What the local pub, local coffee shop offers.
Other Info
Optical Drive:MATSHITA BD-CMB UJ160B ATA Device


Also have an Asus ha1002xp netbook with Win 7 Ultimate installed.
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.
Oh sorry. The file is in the root of D: and there is no pictures folder, because there is no Windows installed on that drive since I only use it for storage.

I still get this error: "The filename, directory name, or volume label syntax is incorrect".

Using "dir Schermafdruk*.*" shows me that the file is present in D:.
 

My Computer My Computer

At a glance

Windows 7 Pro
OS
Windows 7 Pro
Hi Robin,

Try this:

At an elevated command prompt, enter cd /d d:\ in order to switch to the D drive. Next, enter dir to verify the filename(s) of the file(s) you wish to delete.

To delete the file, right-click in the command window and click Mark. Now, highlight the appropriate filename and press Ctrl + C to copy the information to the clipboard. At the command prompt, type del /f " and then right-click + Paste to enter the previously saved information (the filename). Finish by entering " (there should be no spaces between the " characters and the filename) and then execute the command. This should delete the file. Check by reissuing the dir command. Note that you may also use erase instead of del, and if you add the switch /p you will get a confirmation prompt. You will need to repeat this for each file that needs deleting. Copying the filename in this manner removes the possibility of errors creeping in when typing the name, as it is very easy to confuse some characters for others (such as O,o,0 and l,1,i,I to name a few). This misinterpretation of the characters in a filename can often give rise to the error you mention (what you type looks correct, but it isn't).
 

My Computer My Computer

At a glance

Windows 8.1 Pro RTM x64Intel Core-i5-3570K 4-core @ 3.4GHz (Ivy Brid...4 x 4GB DDR3-1600 Corsair Vengeance CMZ8GX3M2...MSI GeForce GTX770 Gaming OC 2GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dwarf Dwf/11/2012 r09/2013
OS
Windows 8.1 Pro RTM x64
CPU
Intel Core-i5-3570K 4-core @ 3.4GHz (Ivy Bridge) (OC 4.4GHz)
Motherboard
ASRock Z77 Extreme4-M
Memory
4 x 4GB DDR3-1600 Corsair Vengeance CMZ8GX3M2A1600C9B (16GB)
Graphics Card(s)
MSI GeForce GTX770 Gaming OC 2GB
Sound Card
Realtek High Definition on board solution (ALC 898)
Monitor(s) Displays
ViewSonic VA1912w Widescreen (VGA)
Screen Resolution
1440x900
Hard Drives
OCZ Agility 3 SSD 120GB SATA III x2 (RAID 0)
Samsung HD501LJ 500GB SATA II x2
Hitachi HDS721010CLA332 1TB SATA II
Iomega 1.5TB Ext USB 2.0
WD 2.0TB Ext USB 3.0
PSU
XFX Pro Series 850W Semi-Modular
Case
Gigabyte IF233
Cooling
1 x 120mm Front Inlet 1 x 120mm Rear Exhaust
Keyboard
Microsoft Comfort Curve Keyboard 3000 (USB)
Mouse
Microsoft Comfort Mouse 3000 for Business (USB)
Internet Speed
NetGear DG834Gv3 ADSL Modem/Router (Ethernet) ~4.0 Mb/s (O2)
Antivirus
Avast! 8.0.1497
Browser
IE 11
Other Info
Optical Drive: HL-DT-ST BD-RE BH10LS30 SATA Bluray
Lexmark S305 Printer/Scanner/Copier (USB)
WEI Score: 8.1/8.1/8.5/8.5/8.25
Asus Eee PC 1011PX Netbook (Windows 7 x86 Starter)
I've tried everything you guys suggested, but it just wouldn't work.

I did find a different way to get rid of the file, which was not the easiest since I encountered some Linux related problems while booting, but it worked! Using a Xubuntu Live usb I could just right click and delete/open/rename/move the file. I had tried Linux virtual machines before since my mobo is UEFI and therefore does not like anything but Windows, but I had trouble sharing files with the machine.

I will rep the ones that gave me some very interesting information, thanks guys!
 

My Computer My Computer

At a glance

Windows 7 Pro
OS
Windows 7 Pro
I did find a different way to get rid of the file, which was not the easiest since I encountered some Linux related problems while booting, but it worked! Using a Xubuntu Live usb I could just right click and delete/open/rename/move the file.

I tried all the DOS and Windows & suggestions here and on another forum and nothing worked. In the end, the only way I could get the file to go away was to open the folder on a Linux virtual machine (which was a bit of trick in itself, mounting the external HD) and delete it.

Thanks, RobinSchouten, for that bit of advice!
 

My Computer My Computer

At a glance

Windows 7 Home Premium 64-bit
OS
Windows 7 Home Premium 64-bit
Back
Top