• Unable to Rename or Delete File/Folder With Long Filename

    Home » Forums » AskWoody support » Windows » Windows 7 » Questions: Windows 7 » Unable to Rename or Delete File/Folder With Long Filename

    Author
    Topic
    #488504

    Try opening a command prompt and deleting the files using DOS commands. You can try deleting them using the short version of the name.

    For example, if the “visible” name is “Thisisaveryveryverylongfilename.mp3”, the short version of the name will likely be thisis~1.mp3.

    You will therefore run the following command: DEL THISIS~1.MP3

    Group "L" (Linux Mint)
    with Windows 10 running in a remote session on my file server
    Viewing 0 reply threads
    Author
    Replies
    • #1383308

      I downloaded some mp3 files from Amazon.com and the filenames turned out to be incredibly long. The resulting path and filenames exceeded 260 characters, so Windows won’t handle them. I tried to rename the files with shorter filenames, but Windows did not allow renaming them. I tried to delete the files with long names and they seemed to disappear. I tried to delete the folder that contained them but could not. I now have the downloaded folder that, when clicked, is shown to be empty (“This folder is empty” is displayed). I checked its properties and it’s reported to contain 1.35 Gb (the size of the music album downloaded). How might I get rid of the “empty” folder that appears to contain 1.35 Gb of data?

      Running Windows 7 Home Premium 64 bit SP1 on HP Elite (1.5 Tb HD) with Intel Core i7 970 @ 3.20 Ghz, 10 Gb memory

      • #1383309

        The annoying part is it’s only Windows Explorer that can’t handle the long names. Windows doesn’t mind.

        Try this in a Command Prompt.
        rd /s first_part_of_subdirectory_name

        e.g. if the file is called “C:tempFilesverylongfilenames.ext”
        rd /s C:tempFiles

        Failing that you should be able to rename the directory to a single character to make the whole lot shorter than 255 characters.

        cheers, Paul

      • #1383310

        Not sure what happened, but the system put my reply ahead of the OP’s post.

        Group "L" (Linux Mint)
        with Windows 10 running in a remote session on my file server
        • #1383322

          mrjimhelps, Paul T and RetiredGeek, I thank you all for your recommendations. Please pardon if my ignorance is shining too brightly. mrjimhelps and Paul T, it appears that I need to be able to see or, at least know, the filenames of the specific files I wish to delete in order to use your suggestions. When I click on the folder (that I wish to delete) that holds the files I wish to delete, nothing shows other than “This folder is empty” so I can’t see the filenames and don’t know them. The path is …my musicamazon mp3various artists[folder I want to delete]. Can I delete the folder using the command prompt to “Del [path]foldername”? I haven’t used DOS in decades.

          RetiredGeek, it looks like a lovely suggestion and I did pull up “Subst /?” via the command prompt. However, the short response left me quaking in my DOS-deficient boots. I’m afraid to attempt that without step-by-step hand holding.

          [As an aside, I did solve the problem of not being able to use the long name files by playing them from the Amazon downloader, recording them and naming the resulting files myself, so all I need to do now is remove the “empty” 1.35 Gb folder.]

          • #1383342

            It appears that I need to be able to see or, at least know, the filenames of the specific files I wish to delete in order to use your suggestions. When I click on the folder (that I wish to delete) that holds the files I wish to delete, nothing shows other than “This folder is empty” so I can’t see the filenames and don’t know them. The path is …my musicamazon mp3various artists[folder I want to delete]. Can I delete the folder using the command prompt to “Del [path]foldername”? I haven’t used DOS in decades.

            Try the following:

            * Open a command prompt.
            * Go to the drive and folder in question.
            –> To get to the drive in question, type C: (put the correct drive letter if it isn’t C)
            –> To get to the correct folder, type CD
            * Type DIR /P (the /P will cause the display to pause after each screenful, so that you can read it)

            If you are in the correct drive and folder, the DIR command should give you the “8.3” or “short” name of the files.

            Once you get the short form of the name, you can then type DEL

            Group "L" (Linux Mint)
            with Windows 10 running in a remote session on my file server
            • #1383358

              Thanks mrjimphelps (apologies for having left the “p” out last time). I got to the desired folder and saw the files I want to delete. The filenames did show up in the long (as opposed to shortened) ~1 form. Unfortunately, I must have either made a typo or inserted “(” when it showed “<" or vice-versa. I wouldn't be surprised if I made typos, as the filename alone has 209 characters (some in German) including () and/or + ext. I’ll try again later with a, hopefully, clearer head and truer typing hands.

              Steve

          • #1383357

            mrjimhelps, Paul T and RetiredGeek, I thank you all for your recommendations. Please pardon if my ignorance is shining too brightly. mrjimhelps and Paul T, it appears that I need to be able to see or, at least know, the filenames of the specific files I wish to delete in order to use your suggestions.

            Neither of their suggestions required filenames, just the folder path.

            When I click on the folder (that I wish to delete) that holds the files I wish to delete, nothing shows other than “This folder is empty” so I can’t see the filenames and don’t know them. The path is …my musicamazon mp3various artists[folder I want to delete]. Can I delete the folder using the command prompt to “Del [path]foldername”? I haven’t used DOS in decades.

            No, but Paul’s suggestion (rd = Remove Directory) was the command to do exactly that.

            Bruce

            • #1383360

              Thank you, Bruce. I better understand that now thanks to your comment and another close look at Paul’s recommendation. I’ll try that.
              Steve

            • #1383719

              Neither of their suggestions required filenames, just the folder path.

              No, but Paul’s suggestion (rd = Remove Directory) was the command to do exactly that.

              Bruce

              You’re right. I didn’t notice the “/s” at the end of the RD command, which allows you to delete a non-empty directory.

              Group "L" (Linux Mint)
              with Windows 10 running in a remote session on my file server
      • #1383316

        Snalmond,

        Another approach would be to open a command prompt and use the Subst command to assign the path, or the first part of the path, to an unused drive letter.

        To get help with the Subst command enter Subst /? at the command prompt. HTH :cheers:

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #1383355

        Snalmond,

        [noparse]
        Syntax SUBST newdriveletter: longdrivepath:
        Example SUBST Q: C:WindowsSystem32PowerShellv1.0en-US
        [/noparse]

        Now can address [noparse]C:WindowsSystem32PowerShellv1.0en-US as simply Q:[/noparse]
        33518-Subst-Example

        To get rid of the substitution simply SUBST /D Q:
        33519-delsubst
        HTH :cheers:

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #1383384

        If you are in the correct drive and folder, the DIR command should give you the “8.3” or “short” name of the files.

        I got to the desired folder and saw the files I want to delete. The filenames did show up in the long (as opposed to shortened) ~1 form.

        Use DIR /X or DIR/-N to display short filenames:

        How to convert a long filename to a short filename

        MS-DOS DIR /X Command – Display short names for non-8dot3 file names

        Bruce

      • #1383771

        Problem solved. This has been an educational experience, and I thank you all for that. I temporarily shortened the names of successive subdirectories and was able to shorten the path sufficiently to allow me to rename those files with monstrously long names. After that I was able to delete the files and the directories in which they resided. Thanks again for your kind assistance.

        Steve

      • #1383775

        There are usually plenty of ways to skin a cat.

        Group "L" (Linux Mint)
        with Windows 10 running in a remote session on my file server
      • #1383845

        Poor cat 🙁

        cheers, Paul

    Viewing 0 reply threads
    Reply To: Unable to Rename or Delete File/Folder With Long Filename

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: