Can't delete file due to invalid file name

Page 1 of 2 12 LastLast

  1. Posts : 67
    Windows 7 Pro
       #1

    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 Computer


  2. Posts : 6,285
    Windows 10 Pro X64
       #2

    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


  3. Posts : 5,092
    Windows 7 32 bit
       #3

    RobinSchouten said:
    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


  4. Posts : 67
    Windows 7 Pro
    Thread Starter
       #4

    Ztruker said:
    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


  5. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #5

    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


  6. Posts : 67
    Windows 7 Pro
    Thread Starter
       #6

    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


  7. Posts : 6,285
    Windows 10 Pro X64
       #7

    Can you post the name of the file?
      My Computer


  8. Posts : 5,092
    Windows 7 32 bit
       #8

    RobinSchouten said:
    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


  9. Posts : 67
    Windows 7 Pro
    Thread Starter
       #9

    MilesAhead said:
    RobinSchouten said:
    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


  10. Posts : 10,200
    MS Windows 7 Ultimate SP1 64-bit
       #10

    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


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 21:10.
Find Us