Renaming Multiple Files

Often times in BIM Management renaming documents, families, sheets and files is a difficult task especially when there are a large number of files. Renaming files can be important for maintaining project or company standards and this becomes a daunting task to do manually. On the software side of the issue, sometimes company IT restrictions can make it difficult for BIM Managers to request or execute third-party software for batch renaming files. Use these native powershell scripts to help rename multiple files that is readily available in Windows 10.

Accessing Powershell in Windows 10

To access Powershell, hold Shift and Right-Click a blank space in a folder in which you would like to execute Powershell scripts. The file path will automatically update when Powershell opens.

Note that in the scripts below "Dir |" and "Get-ChildItem |" perform the same function.

To replace spaces with an underscore or replace text.

Dir | Rename-Item -NewName { $_.Name -replace " ","_" }

Add a Prefix

Dir | Rename-Item -NewName { "Prefix_" + $_.Name }

Add a Suffix

Dir | Rename-Item -NewName { $_.basename + "_Suffix” +  $_.extension}

To find “_word” and delete

Dir | Rename-Item -NewName { $_.Name -replace "_word","" }

To rename only one file, use the following command:

Dir | Rename-Item "original_filename.ext1" "new_filename.ext1"

Rename All Files to Uppercase

All three of these perform the same function.

Dir | Rename-Item -NewName {$_.BaseName.ToUpper() + $_.Extension.ToLower()}

Get-ChildItem | % { Move-Item -Path $_ -Destination (($_.BaseName.ToUpper())+($_.Extension.ToLower())) }

Get-ChildItem | %{ $newFilename = ($_.BaseName.ToUpper())+($_.Extension.ToLower()); Move-Item $_ $newFilename }

Rename All Files to Title Case

This will maintain the extension casing while only changing the file name.

$text = [System.Threading.Thread]::CurrentThread.CurrentCulture.TextInfo

Get-ChildItem | Rename-Item -NewName { "$($text.ToTitleCase($_.BaseName))$($_.Extension)" }

Rename All Files to Lowercase

Dir | Rename-Item -NewName {$_.BaseName.ToLower() + $_.Extension.ToLower()}


2 Comments

CG1254 · August 18, 2020 at 4:46 am

Didn’t work. Maybe make your instructions clearer or update them so they do work.

John B · December 14, 2021 at 7:00 am

Prefix worked perfectly for me, thanks.

Leave a Reply

Avatar placeholder