Share via

Filename got extra space at the end and unable to replace the file

Sudheer 0 Reputation points
2026-04-16T17:02:25.3766667+00:00

Hi, Ex-employee has uploaded a pdf file in SharePoint with extra space at the end. Now, we are trying to modify that and replace the file, but we are not able to do that because of the extra space. Basically, unable to save the file with extra space. Please advise.

Regards,
[Moderator note: personal info removed] 

 

Microsoft 365 and Office | SharePoint | Development
0 comments No comments

1 answer

Sort by: Most helpful
  1. Hin-V 14,180 Reputation points Microsoft External Staff Moderator
    2026-04-16T18:50:31.03+00:00

    Please note that our forum is a public platform, and we will modify your question to hide your personal information in the description. Kindly ensure that you hide any personal or organizational information the next time you post an error or other details to protect personal data.  

    Hi @Sudheer

    Good day, I hope you are doing well.  

    Looks like you are encountering an classic SharePoint / OneDrive filename restriction. SharePoint does not allow trailing spaces (or leading spaces) in file names. Even though the file was uploaded with an extra space at the end, the system treats a filename with a trailing space as different from the same name without the space. This is why you cannot easily replace or overwrite the file. 

    image

    You could try to rename the existing file to remove the trailing space to troubleshoot it: 

    Go to the SharePoint document library in your browser. 

    Find the PDF file. 

    Click the ⋯ (ellipsis) next to the file > Rename. 

    Remove the extra space at the end of the filename (make sure it ends with .pdf with no space before it). 

    Click Save / Rename. 

    After renaming, try uploading your new version again, it should now overwrite properly. 

    If renaming does not work, you could try to upload your new PDF with a slightly different name (filename - updated.pdf). 

    Once uploaded, delete the old file that has the trailing space. 

    Then rename the new file to the correct name. 

    Additionally, you may try using a PowerShell cmdlet to resolve this issue by explicitly renaming the file to remove the trailing space. Run: 

    Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/SiteName -Interactive 
    Rename-PnPFile ` 
      -ServerRelativeUrl "/sites/yoursite/Shared Documents/YourFileName .pdf" ` 
      -TargetFileName "YourFileName.pdf" ` 
      -Force 
    `` 
    

    References: 

    Restrictions and limitations in OneDrive and SharePoint - Microsoft Support 

    powershell/documentation/Rename-PnPFile.md at dev · pnp/powershell · GitHub 

    I hope this helps. 

    Please understand that our initial reply may not always immediately resolve the issue. However, with your help and more detailed information, we can work together to find a solution. 


    Note: Please follow the steps in [our documentation] to enable e-mail notifications if you want to receive the related email notification for this thread. 

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.