[PowerShell] Renaming All Files in a Folder with a Prefix

A very simple bit of code. Use PowerShell CLI. Navigate to the folder within which you want to rename the files (using cd). Then run (setting your prefix to what you want it to be):

$prefix = "PREFIX"; $items=Get-ChildItem; $items | Rename-Item -NewName { $prefix + ($_.Name) };

## Broken down to make it clearer:

$prefix = "PREFIX"
$items=Get-ChildItem
$items | Rename-Item -NewName { $prefix + ($_.Name) }

Nice and easy 😊


Note: To do the code block I'm using the below from: How to add code snippets in blogger posts | by Tarak Shah | Medium

Comments