Skip to content
Home » Microsoft » Windows » How to Delete a PDF File with Long Name Using PowerShell

How to Delete a PDF File with Long Name Using PowerShell

Have you ever struggled to delete a PDF file because its name exceeds the limitations? Whether it’s due to a pesky character limit or an overly long and convoluted file name, trying to delete an unwanted PDF can be frustrating. Names beyond a proper limit can make it difficult to copy, move, rename, or delete a file. Below, I’ll walk you through a quick and effective solution to delete a stubborn PDF file with an excessively long file name on Windows 10 and 11.

You can delete files and folders via PowerShell using advanced parameters but when it comes to removing files with long names, you have to use the del command instead of Remove-Item.

Recently, I struggled with renaming and deleting a PDF file from my desktop. I was fined for unauthorized car parking. After paying the fine amount online, I downloaded the PDF receipt to the desktop. It opened normally in Google Chrome but later, I noticed that the name of the PDF file was too long. pdf file on windows desktop with very long name

echallan.parivahan.gov.in_report_print-challan-receipt_data=tM3pJ01qgJECukxDSxFLFedcTWVTluS958p4lTVFZH7TNy8Uwc6a69YC9T5X0CH%2FWMwoVYuW32l3Cy7eGNgJwgB0YKLD6ycbHzDkh3yJ8asmOcroqXEb1vZQOEBY1Ajp6q2UPIRvX1pXOo1jVWAwSBM0567J7roSFhtE6MZFOnNFLUfmdjVJ1X9vI25VK.pdf

When I tried to rename the PDF file because I wanted to assign it a short name, I couldn’t do that. Suspecting that it might be malware, I tried to delete it instantly but it was futile. Then I tried to move the PDF file to a folder to delete it along with the folder but I failed. delete pdf from desktop windows 11

Having done some research online and testing different methods, I finally succeeded in deleting the PDF file with a long name from my desktop using a Windows PowerShell command.

Deleting a File with a Long Name Using PowerShell

The reason why you can’t delete a text or PDF file from your desktop may be because its name is too long. The root cause of this irritating problem lies in LFN. Windows uses a naming convention called LFN (long filename). The LFN system allows the operating system to recognize files and directories that use up to 255 characters in their names.

Just like LFN (long filename), Windows also supports the SFN (short filename) convention used by DOS. It works like an alternative filename system in Windows 10 and 11. SFN (aka 8.3 filename) is limited to 8 characters followed by a file extension. The backward compatibility of Windows assigns an 8-character short filename to the file whose filename exceeds 255 characters.

For instance, the PDF file name I mentioned above also had a short filename consisting of only 8 characters. Once you have that SFN or 8.3 filename, you can easily delete any file with a long name using the DEL command in the PowerShell or the Windows Command Prompt.

Let’s see how to do it.

  1. Right-click on the file whose name is too long and choose the Copy as path option to copy the file path. copy as path option in windows 11
  2. Now, paste the copied file path into a text file. The path will contain the 8-character short filename of the file you can’t delete. In my case, the short filename of the PDF file I mentioned above was ‘ECHALL~1.PDF‘ as in “C:\Users\droid\Desktop\ECHALL~1.PDF”
  3. Copy the short filename to the clipboard.
  4. Now, navigate to the directory or desktop where that stubborn file is located.
  5. Hold the Shift key, right-click on an empty area, and select the Open in Terminal or Open PowerShell window here option from the Windows context menu.open powershell window here windows 11
  6. Execute the DEL command followed by the filename (with extension) of the file you want to delete.
    DEL Filename.PDF

    delete file with long name using windows powershell

  7. As soon as you hit Enter, the file you couldn’t delete earlier will be deleted.

The deleted file will disappear from your computer completely. It won’t be sent to the Recycle Bin. Using this method, you can delete any file with a long name. It doesn’t matter whether it is a PDF or text file or has any other extension.

Hopefully, this step-by-step guide has helped you figure out how to delete a PDF when the file name exceeds limitations. This process can be tricky, but with our tips, you’ll be able to make sure your files are correctly named and organized so that they don’t cause any further issues in the future. If you find yourself needing additional assistance with managing your PDFs or other documents, feel free to reach out for help from one of our experts.

Read Next: 250+ Windows 10/11 Keyboard Shortcuts

Rakesh Shukla

Rakesh Shukla

Rakesh is a geek by heart with an ardent passion for all things tech. From a young age, he was drawn to the world of technology and found himself constantly tinkering with gadgets and devices. He enjoys learning and discovering the newest trends in the world of Android, iOS, and Windows.View Author posts