Forum Discussion

TheNoobOfSP's avatar
TheNoobOfSP
Copper Contributor
Feb 25, 2025

Original Image Name Vs GUID

I am trying to figure out why when exporting into a CSV or Excel straight out of Sharepot Online that the original image name is not kept but is replaced by a GUID number? This used to work when pulling an Export of a list and it would show the real file name. (Pics below).

 

In the "List View" when hovering over the picture the original file name appears.

 

Yet when you pull the Excel export it shows this.

Why are they including both the GUID and the original file name and is there a way to only show the original file name under the column?

 

Thanks everyone.

1 Reply

  • 1. Methods to get the original file name
    Query the file name through PowerShell
    powershell
    Connect-PnPOnline -Url “https://contoso.sharepoint.com/sites/site”
    Get-PnPFile -Url “/sites/site/DocLib/2F3A4B50-1A2B-4C5D-6E7F-123456789ABC.jpg” | 
    Select-Object Name,@{N=“OriginalName”;E={$_.ListItemAllFields[“FileLeafRef”]}}
    2. Via REST API
    http
    GET https://contoso.sharepoint.com/sites/site/_api/web/getfilebyserverrelativeurl('/sites/site/DocLib/2F3A4B50-1A2B-4C5D-6E7F- 123456789ABC.jpg')/listitemallfields?$select=FileLeafRef
    Headers.
    - Accept: “application/json;odata=verbose”
    3. Keep the original naming solution
     Rename the file before uploading
    powershell
    # Use PnP PowerShell to keep the original name
    Add-PnPFile -Path “logo.jpg” -Folder “Shared Documents” -NewFileName “logo.jpg” -Values @{“Title”=“Company Logo”}
    4. Disable automatic renaming (requires administrator privileges)
    powershell
    Set-PnPList -Identity “Documents” -EnableAssignUniquePermissions $false
    5. Development Considerations
    Front-end display processing
    javascript
    // Get the original name from the list item
    const originalName = item.FileLeafRef; 
     Streaming Upload Optimization
    csharp
    // CSOM code example
    FileStream fs = new FileStream(“photo.jpg”, FileMode.Open);
    FileCreationInformation flci = new FileCreationInformation(); flci.
    flci.Overwrite = true; flci.ContentStream = f
    flci.Url = “photo.jpg”; // force the original name to stay

Resources