Powershell : Updating Filename with a Script


This is a quick post to cover a file operation update that ensured the filenames were compatible to a automation system, we received files from an externally facing service and we need to ensure that the file tag or "bear" before the filename was removed.

The files were standard zip files and looked liked this when received from external sources:


Script : AlterFileName.ps1

Get-ChildItem "C:\ExternalData\*.zip" | ForEach-Object {
    $newName = $_.Name -replace '^bear_', ''
    Rename-Item -Path $_.FullName -NewName $newName
}

This should then remove the bear_ as you can see below, it has, mission accomplished:

Previous Post Next Post

نموذج الاتصال