Wednesday, April 17, 2019

File Rename Script

Just a quick script to rename all files in a folder:

$theFolder = "\\server.domain.com\share\folder"
$theFiles = (Get-ChildItem -Path $myFolder -Filter Prefix*.type ).Name
foreach ($File in $myFiles)
{
    $FullPathFileName = $theFolder + "\" + $File
    $newName = ($File).Replace(" ","_")
    Rename-Item -Path $FullPathFileName -NewName $newName -Force
}