When file names are too long and windows won’t delete or rename for that reason, and dir /x doesn’t work in CMD, here’s one way to delete the file

Step 1: Locate file that is too long

49132e03283126505b8d42f70e447d1d6b7940ead9be727064bee7c9b10580ce_file-name-too-long.jpg

Find the path of the file with the filename that is too long to delete

Step 2: Open 7-zip or winrar

1f0d53362bf22f3314f87276d470157df47865d356036b5f953cab76f7c7ef38_file-name-too-long2.jpg

Navigate to the file, as if your going to create an archive withing the 7-zip or winrar application, right click on the file (or F2) and choose rename. Give the file a shorter name.

Step 3: You can now delete the file in file explorer

Success! the file now has a shorter name and can be deleted.

This worked well for me after my other option didn’t work, opening the directory in a command prompt and using dir /x to display shorter names and deleting from there. The only listing it would give me would be the long file name again.
This method of renaming within 7-zip seems much simpler than the MS article outlining other ways of deleting a file with a filename too long, Can't delete files on NTFS file system - Windows Server | Microsoft Learn

Hope this helps someone

6 Spice ups

Can’t you just right click and rename? Just curious. Thanks

When it’s too long, the right click menu gives you “Open, print, edit, mediainfo, open with, send to” no rename or delete. Plus shift-Delete and f2 do not work on these files either, I’m sure there is a work around but 7-zip is just so simple

Map a drive to the file location \computername\adminshare\folderpath and then delete the file ie \mypc\c$\folders. It can be on the same machine. It shortens the folder name to a single letter, then select the file name and then you can delete it.

2 Spice ups

Thanks for this. I used 7-Zip to rename two files and delete them out of a file server and backup versions on our NAS. They were both files saved by former staff and nobody here now needs them or wants them. The 7-Zip method was quick and easy for me. +100

Use "Long Path This very useful if you are having problems
in deleting, unlocking, copying and even renaming files, also very easy. - Juan Miller

I can’t believe how easy this was to fix. Very nice workaround to a common problem. I never understood why MS allows the creation of long file names to begin with if you can’t manipulate them after the fact. Anyway, thanks for the tip. :+1:t3:

1 Spice up

Simply download the below tool and get rid of any file whatever…not a rocket science bro…
https://fileassassin.en.softonic.com/?ex=RAMP-2046.2

Thanks, It helps alot. :pray:

Simply download and install LongPathTool software you can use this app to delete,move rename file with long filename.