Say I have a list of file names like this:
some-file.ts
my-project-service.ts
other.ts
something-my-project.ts
my-project
$appname$
my-project-service.ts
$appname$-service.ts
Use the Get-ChildItem
cmdlet with the -recurse
switch to get all items recursivly from a root directory. Filter all items containing my-project
using the Where-Object
cmdlet and finally rename them using the Rename-Item
cmdlet:
Get-ChildItem "D:\tmp" -Recurse |
Where {$_.Name -Match 'my-project'} |
Rename-Item -NewName {$_.name -replace 'my-project','$appname$' }