Struggling to delete files with long names in Windows? This post will show how to delete long path files in Windows if the system refuses to delete the selected files.
“When I try to delete the directory using Explorer, I receive the following error: —Cannot delete [file name]: The file name you specified is not valid or too long; and when I used Powershell, I received the following error: Remove -Item: The supplied path, file name, or both are insufficiently lengthy. The fully qualified file name and the directory name must be smaller than 260 and 248 characters, respectively. Line 1 char 12 + - Remove-Item - force –Recurse
Is it possible to safely remove lengthy path files in Windows and thoroughly delete large files in Windows?
When attempting to remove some files, because Windows accepts file names with up to 260 characters, including the directory path, a directory or file, if the selected files or folder exceeds the limit, it cannot be operated.
This problem causes a lot of hassle when users wish to remove a directory or a deeply stored file. Thus, in this post, we list 2 workable solutions to help you force delete long name files.
To resolve the problem that is caused by the system, the best way is to use the system built-in tool. In this part, we’ll show you how to delete long path files in Windows with Command Prompt orders. There are 2 ways to solve the problem, the commands might be a little complex, please be careful.
Step 1. e Explorer and navigate to the directory where the target files are located. Press and hold Shift, then right-click on an empty area. Choose “Open command window here”.
Step 2. Type: DIR /X, if the directory contains more files than can be displayed on a single screen, use the command DIR /X /P instead so that it will pause at every screen length so you can examine the file list.
DIR /X command will list all the directories and files in the current directory, and it will also list all the files and directories. In the example, you can see how the dummy txt file with a nonsensical (and hundreds of characters long) filename is reduced to a simple “WHYSOL~1.TXT”.
So now we need to arm it with the short name of the file or directory you wish to delete, you can simply issue a DEL command for the file.
Step 3. Type: DEL WHYSOL~1.TXT
Then Windows will delete the file without complaint, and you can run DIR /X again to confirm or just check the directory in Windows Explorer.
You can also use robocopy commands.
Step 1. Type CMD in the search box and right-click the best match, choose “Run as administrator”. Now, create an empty directory, you can type: mkdir C:\emptyfolder
Step 2. Type the following lines and press “Enter”.
Robocopy C:\emptyfolder C:\name of folder/purge
For example, if the name of the newly created folder is “C:\EmptyFolder” and the folder with a long path is “C:\FolderToBeCleaned\Copy\MyFiles\BackupFolder\Copy\MyFile…”, then the deleting command is “robocopy C:\Emptyfolder C:\FolderToBeCleaned /purge”.
Then the files in the target path will be removed.
Some users may think that deleting files is a simple task. However, if you meet the above situation, deleting files can also be an annoying problem. Just like the files with a long name, files with large sizes stored deeply in the system also cannot be removed easily. Users might not even know their existence. But they will find that no matter how many times they use a cleaning program to clear the system and disks, there always have some available space occupied by some unknown files.
If you have such a problem, it’s possible that some large files have been recognized as important by your system like exe files. Since you can’t find them in File Explorer, the best choice is to use a third-party tool to scan them and you can remove them according to your needs.
Here, we recommend you AOMEI Partition Assistant Professional, a disk and partition manager for Windows 11/10/8/8.1/7 users. Its “Delete Large Files” function can filter all large files and list them for you to choose to remove.
Free Up Disk Space To Keep Your PC Running Smoothly and Efficiently
Step 1. Initiate Delete Large Files. Install and launch AOMEI Partition Assistant for Cleanup. Click the "Delete Large Files" tab.
Step 2. Select a path to scan large files. You can either click "Scan System Drive" to start the scan of your system C: drive. Or, click "Custom Scan" to manually select paths to be scanned. (Here, we take the "Custom Scan" as an example.)
Step 3. After clicking "Custom Scan", all local and external drives on your PC and the common Desktop, Documents, and Downloads paths will be displayed. You can manually select paths to be scanned. Once necessary paths are added, you can click the "Scan Now" button to start the scan process.
Step 4. The scan process might take time. After the scan is complete, all large files found will be listed.
Step 5. You can also check the large files and click the button behind to locate them.
Step 6. Select large files to start deletion. Tick the files you want to delete, and then click the "Clean Now" button to start the deletion.
Step 7. Delete successfully. The deletion might take time. After the process is finished, the selected files will be deleted, and you will get a cleaning completed window displaying how much data you deleted in total.
In this post, we show you two methods for how to delete long-path files in Windows. If you have files with names too long, you can try the methods above. And if you wish to clear some deeply stored files, AOMEI Partition Assistant for Cleanup can help you. In addition, this tool also supports Windows Server system 2022/2019/2016/2012(R2).
Windows has a maximum path length limitation of 260 characters. When a file's path exceeds this limit, standard operations like deletion may fail because the system cannot process such long paths.
To avoid encountering long path issues:
LongPathsEnabled registry key to 1.You can use built-in tools like Command Prompt with commands such as DEL or ROBOCOPY to handle long path files. These tools can bypass the standard path length limitation by utilizing extended-length paths.