Renaming Files With Trailing Spaces ” ” in Windows Explorer

As part of my job as IT support I see and experience many different issues. Most of them are well documented online in forums, blog posts or in technical documentation, but then there are some that just really boggle your mind. This situation is one of those, and I found the fix by chance in a comment on a blog post!

Scenario

In my case I had an issue with some backup software where it was failing to read some files on a file server, skipping them entirely.

After contacting the backup vendor support they informed me the issue was that the files:

  1. Did not have a file extension
  2. Had trailing space (” “) characters at the end of their file names

These files had been generated by a Linux based embedded system which is used as part of a packaging line for one of our clients. Linux (and apparently also Macintosh) file systems allow you save files with a space at the end of the filename, Microsoft Windows however does not.

When I would open Windows Explorer to the location of the files I found that when I tried to:

  1. Rename
  2. Read properties
  3. Open/read data

I would receive this very ambiguous message from Windows:

Could not find this item. This is no longer located in [Path]. Verify the item’s location and try again.

As the folder path was rather long, coming in at around 288 characters, I first thought there was an issue with the long path name that Windows has suffered for many years – however my go-to fixes (such as using the subst command) returned the same error, file not found.

I went through many different “solutions” online to no avail, until I found the fix which luckily for me and my client is free and very easy to use!

The Fix

Assumptions

The following is assumed:

  • You have Full Control or Modify rights over this folder
  • You are able to log in as a Local or Domain administrator to install applications
  • You are using a modern Windows operating system, no earlier than Windows 7 (although I could see this fix working as far back as Windows XP)
  • You have the File name extensions enabled in Windows Explorer

Process

  1. Connect to the device in question and log in as a user with administrative rights
  2. Download the latest edition of 7-Zip from their website: https://www.7-zip.org/
    1. Download the 32-bit or 64-bit version depending on your operating system architecture
  3. Install the downloaded application
  4. From the Start Menu go to All Programs and then open the 7-Zip folder and then start 7-Zip File Manager
  5. Using Windows Explorer navigate to the folder which contains the problem file(s)
  6. Click in the address bar of the Windows Explorer window and copy the file path
  7. Click back into 7-Zip File Manager and paste the path into the address bar and then hit Return/Enter on your keyboard
  8. 7-Zip File Manager should now show the directory that houses the problem files
  9. Right click on the problem files and choose Rename or press the F2 key on your keyboard
  10. Remove the trailing space key and provide a file extension if it is missing
  11. You should now be able to amend/read/modify the file in Windows explorer and all applications should be OK to access these files.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.