Renaming bulk files in ProjectWise while referencing an Excel or .csv file

Hello,

We have a few hundred files in ProjectWise that need to be renamed due to client requirements. Right now, we have the these files and their path, along with the current file name and new name in respective columns, saved in both an Excel and a .csv file. Is there way to reference this excel/csv file in PowerShell to rename all these files in ProjectWise? I'm still learning PowerShell and unsure on how to get this completed right now. 

Thank you for any possible help

Parents
  • Hi Brian, 

    Yes this is something I have done before and it works well. If you look at ImportExcel on PowerShell Gallery and install it on your machine, it can read in the contents of an Excel file (Import-Excel) and create a PowerShell object for each row. Then for each object (i.e. row) you can use some of the cmdlets in the PWPS_DAB module to find the document in ProjectWise (Get-PWDocumentsBySearch) and rename it accordingly (Rename-PWDocument).

    I've included some sample code and images below to help explain.

    # Import your data from Excel
    $ImportData = Import-Excel -Path "C:\Temp\MyData.xlsx" -WorksheetName "Data"
    
    # If you want to see the data to check what has been imported
    $ImportData
    
    # Loop through each imported record
    ForEach($Record in $ImportData)
    {
        # Search for the document in PW by Folder Path and File Name
        $PWDoc = Get-PWDocumentsBySearch -FolderPath $Record.PWFolderPath -DocumentName $Record.OldFileName
       
        # Set the new name for the document
        Rename-PWDocument -InputDocument $PWDoc -DocumentNewName $Record.NewFileName
    }

    Best Regards,

    Ian

Reply
  • Hi Brian, 

    Yes this is something I have done before and it works well. If you look at ImportExcel on PowerShell Gallery and install it on your machine, it can read in the contents of an Excel file (Import-Excel) and create a PowerShell object for each row. Then for each object (i.e. row) you can use some of the cmdlets in the PWPS_DAB module to find the document in ProjectWise (Get-PWDocumentsBySearch) and rename it accordingly (Rename-PWDocument).

    I've included some sample code and images below to help explain.

    # Import your data from Excel
    $ImportData = Import-Excel -Path "C:\Temp\MyData.xlsx" -WorksheetName "Data"
    
    # If you want to see the data to check what has been imported
    $ImportData
    
    # Loop through each imported record
    ForEach($Record in $ImportData)
    {
        # Search for the document in PW by Folder Path and File Name
        $PWDoc = Get-PWDocumentsBySearch -FolderPath $Record.PWFolderPath -DocumentName $Record.OldFileName
       
        # Set the new name for the document
        Rename-PWDocument -InputDocument $PWDoc -DocumentNewName $Record.NewFileName
    }

    Best Regards,

    Ian

Children