Tech Blog, Tips and Tricks

Deleting a File when the Filename is too Long

How to delete a file when the filename is too long.
By creating a temporary substitute drive, we can shorten the file name, allowing you to rename, delete, etc.

As you can see in the commands, I tried shortening the folders to 1 without success.

Open up File explorer, Go to the location of the long file, in the address bar of File Explorer, type CMD.  This will open a Command Window at the location of the file that is too long.

In this Example we will create the “Q” drive, Choose a different drive letter“Q:” if you already have that letter assigned to a different drive. For this test, our folder was E:\1\1\1\1\1.
Type subt Q: E:\foldername

This will create a substitution drive for that folder.
Open File Explorer, and in the Address Bar, type Q:\

This will then open that folder as if its Drive Q, which should allow you to then delete the file manually.

Finally delete the substituted Drive
In that same cmd window type SUBST /D Q:

Leave a Reply

Your email address will not be published. Required fields are marked *