Notice: Due to size constraints and loading performance considerations, scripts referenced in blog posts are not attached directly. To request access, please complete the following form: Script Request Form Note: A Google account is required to access the form.
Disclaimer: I do not accept responsibility for any issues arising from scripts being run without adequate understanding. It is the user's responsibility to review and assess any code before execution. More information

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

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